void SetPredecessor(const Node &node, const Node &parent) { // Try to find the given node in the node_parent_map node_parent_iterator it = node_parents.find(node); if (it == node_parents.end()) // first entry // If the node wasn't found // -> Insert a new node into the node_parent_map node_parents.insert(std::make_pair(node, parent)); else // If the node was found // -> Replace the according parent node with the new one it->second = parent; }
/** * Find best predecessor found so far to the specified node * * @param n Node as destination to find best predecessor for * * @return Predecessor node */ gcc_pure Node GetPredecessor(const Node &node) const { // Try to find the given node in the node_parent_map node_parent_const_iterator it = node_parents.find(node); if (it == node_parents.end()) // first entry // If the node wasn't found // -> Return the given node itself return node; // If the node was found // -> Return the parent node return it->second; }