lemon/smart_graph.h
changeset 1768 1e2e0238e7c8
parent 1729 06f939455cb1
child 1770 657de7e5043c
equal deleted inserted replaced
8:98ed71cd36f9 9:bd28c39dac84
   212     
   212     
   213     void nextIn(Edge& edge) const {
   213     void nextIn(Edge& edge) const {
   214       edge.n = edges[edge.n].next_in;
   214       edge.n = edges[edge.n].next_in;
   215     }
   215     }
   216 
   216 
   217     Edge _findEdge(Node u,Node v, Edge prev = INVALID) 
       
   218     {
       
   219       int e = (prev.n==-1)? nodes[u.n].first_out : edges[prev.n].next_out;
       
   220       while(e!=-1 && edges[e].target!=v.n) e = edges[e].next_out;
       
   221       prev.n=e;
       
   222       return prev;
       
   223     }
       
   224 
       
   225     Node _split(Node n, bool connect = true)
   217     Node _split(Node n, bool connect = true)
   226     {
   218     {
   227       Node b = addNode();
   219       Node b = addNode();
   228       nodes[b.n].first_out=nodes[n.n].first_out;
   220       nodes[b.n].first_out=nodes[n.n].first_out;
   229       nodes[n.n].first_out=-1;
   221       nodes[n.n].first_out=-1;
   254   ///\sa concept::ExtendableGraph.
   246   ///\sa concept::ExtendableGraph.
   255   ///
   247   ///
   256   ///\author Alpar Juttner
   248   ///\author Alpar Juttner
   257   class SmartGraph : public ExtendedSmartGraphBase {
   249   class SmartGraph : public ExtendedSmartGraphBase {
   258   public:
   250   public:
   259     /// Finds an edge between two nodes.
       
   260     
       
   261     /// Finds an edge from node \c u to node \c v.
       
   262     ///
       
   263     /// If \c prev is \ref INVALID (this is the default value), then
       
   264     /// it finds the first edge from \c u to \c v. Otherwise it looks for
       
   265     /// the next edge from \c u to \c v after \c prev.
       
   266     /// \return The found edge or \ref INVALID if there is no such an edge.
       
   267     ///
       
   268     /// Thus you can iterate through each edge from \c u to \c v as it follows.
       
   269     /// \code
       
   270     /// for(Edge e=G.findEdge(u,v);e!=INVALID;e=G.findEdge(u,v,e)) {
       
   271     ///   ...
       
   272     /// }
       
   273     /// \endcode
       
   274     /// \todo Possibly it should be a global function.
       
   275     Edge findEdge(Node u,Node v, Edge prev = INVALID) 
       
   276     {
       
   277       return _findEdge(u,v,prev);
       
   278     }
       
   279     
   251     
   280     class SnapShot;
   252     class SnapShot;
   281     friend class SnapShot;
   253     friend class SnapShot;
   282 
   254 
   283   protected:
   255   protected: