src/lemon/list_graph.h
changeset 1281 164ca6938d09
parent 1184 aad134c6c9c5
child 1284 b941d044f87b
equal deleted inserted replaced
20:39a907751f34 21:ab106f74bcbe
   366     ///its neighboring edges, they will be joined to \p a.
   366     ///its neighboring edges, they will be joined to \p a.
   367     ///The last parameter \p r controls whether to remove loops. \c true
   367     ///The last parameter \p r controls whether to remove loops. \c true
   368     ///means that loops will be removed.
   368     ///means that loops will be removed.
   369     ///
   369     ///
   370     ///\note The <tt>Edge</tt>s
   370     ///\note The <tt>Edge</tt>s
   371     ///referencing the moved edge remain
   371     ///referencing a moved edge remain
   372     ///valid. However <tt>InEdge</tt>'s and <tt>OutEdge</tt>'s
   372     ///valid. However <tt>InEdge</tt>'s and <tt>OutEdge</tt>'s
   373     ///may be invalidated.
   373     ///may be invalidated.
   374     void contract(Node a,Node b,bool r=true) 
   374     void contract(Node a,Node b,bool r=true) 
   375     {
   375     {
   376       for(OutEdgeIt e(*this,b);e!=INVALID;) {
   376       for(OutEdgeIt e(*this,b);e!=INVALID;) {
   388 	e=f;
   388 	e=f;
   389       }
   389       }
   390       erase(b);
   390       erase(b);
   391     }
   391     }
   392 
   392 
   393 
   393     ///Split a node.
       
   394 
       
   395     ///This function splits a node. First new node is added to the graph, then
       
   396     ///the source of each outgoing edge of \c n is moved to this new node.
       
   397     ///If \c connect is \c true (this is the default value), then a new edge
       
   398     ///from \c n to the newly created node is also added.
       
   399     ///\return The newly created node.
       
   400     ///
       
   401     ///\note The <tt>Edge</tt>s
       
   402     ///referencing a moved edge remain
       
   403     ///valid. However <tt>InEdge</tt>'s and <tt>OutEdge</tt>'s
       
   404     ///may be invalidated.
       
   405     ///\todo It could be implemented in a bit faster way.
       
   406     Node split(Node n, bool connect = true) 
       
   407     {
       
   408       Node b = addNode();
       
   409       for(OutEdgeIt e(*this,n);e!=INVALID;) {
       
   410  	OutEdgeIt f=e;
       
   411 	++f;
       
   412 	moveSource(e,b);
       
   413 	e=f;
       
   414       }
       
   415       if(connect) addEdge(n,b);
       
   416       return b;
       
   417     }
       
   418       
   394     ///Class to make a snapshot of the graph and to restrore to it later.
   419     ///Class to make a snapshot of the graph and to restrore to it later.
   395 
   420 
   396     ///Class to make a snapshot of the graph and to restrore to it later.
   421     ///Class to make a snapshot of the graph and to restrore to it later.
   397     ///
   422     ///
   398     ///The newly added nodes and edges can be removed using the
   423     ///The newly added nodes and edges can be removed using the