Example #1
0
 /**
  * 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 get_predecessor(const Node &node) const {
   // Try to find the given node in the node_parent_map
   edge_const_iterator it = edges.find(node);
   if (it == edges.end())
     // first entry
     // If the node wasn't found
     // -> Return the given node itself
     return node;
   else
     // If the node was found
     // -> Return the parent node
     return it->second.parent;
 }
Example #2
0
  /**
   * Add node to search queue
   *
   * @param n Destination node to add
   * @param pn Previous node
   * @param e Edge distance (previous to this)
   */
  void push(const Node &node, const Node &parent, unsigned edge_value = 0) {
    // Try to find the given node n in the edge_map
    edge_iterator it = edges.find(node);
    if (it == edges.end())
      // first entry
      // If the node wasn't found
      // -> Insert a new node
      it = edges.insert(std::make_pair(node, Edge(parent, edge_value))).first;
    else if (it->second.value > edge_value)
      // If the node was found and the new value is smaller
      // -> Replace the value with the new one
      it->second = Edge(parent, edge_value);
    else
      // If the node was found but the new value is higher or equal
      // -> Don't use this new leg
      return;

    q.push(Value(edge_value, it));
  }