# HG changeset patch
# User alpar
# Date 1112277853 0
# Node ID b941d044f87b1bc1766e8922c7e6b319f10300a5
# Parent fc20371677b9930367a6f524493c2e6a92785a9f
SmartGraph can also split() a node!
diff -r fc20371677b9 -r b941d044f87b src/lemon/list_graph.h
--- a/src/lemon/list_graph.h Thu Mar 31 13:31:39 2005 +0000
+++ b/src/lemon/list_graph.h Thu Mar 31 14:04:13 2005 +0000
@@ -392,8 +392,8 @@
///Split a node.
- ///This function splits a node. First new node is added to the graph, then
- ///the source of each outgoing edge of \c n is moved to this new node.
+ ///This function splits a node. First a new node is added to the graph,
+ ///then the source of each outgoing edge of \c n is moved to this new node.
///If \c connect is \c true (this is the default value), then a new edge
///from \c n to the newly created node is also added.
///\return The newly created node.
@@ -402,6 +402,8 @@
///referencing a moved edge remain
///valid. However InEdge's and OutEdge's
///may be invalidated.
+ ///\warning This functionality cannot be used together with the SnapShot
+ ///feature.
///\todo It could be implemented in a bit faster way.
Node split(Node n, bool connect = true)
{
diff -r fc20371677b9 -r b941d044f87b src/lemon/smart_graph.h
--- a/src/lemon/smart_graph.h Thu Mar 31 13:31:39 2005 +0000
+++ b/src/lemon/smart_graph.h Thu Mar 31 14:04:13 2005 +0000
@@ -219,6 +219,16 @@
return prev;
}
+ Node _split(Node n, bool connect = true)
+ {
+ Node b = addNode();
+ nodes[b.n].first_out=nodes[n.n].first_out;
+ nodes[n.n].first_out=-1;
+ for(int i=nodes[b.n].first_out;i!=-1;i++) edges[i].source=b.n;
+ if(connect) addEdge(n,b);
+ return b;
+ }
+
};
typedef AlterableGraphExtender AlterableSmartGraphBase;
@@ -284,6 +294,28 @@
}
public:
+
+ ///Split a node.
+
+ ///This function splits a node. First a new node is added to the graph,
+ ///then the source of each outgoing edge of \c n is moved to this new node.
+ ///If \c connect is \c true (this is the default value), then a new edge
+ ///from \c n to the newly created node is also added.
+ ///\return The newly created node.
+ ///
+ ///\note The Edges
+ ///referencing a moved edge remain
+ ///valid. However InEdge's and OutEdge's
+ ///may be invalidated.
+ ///\warning This functionality cannot be used together with the SnapShot
+ ///feature.
+ ///\todo It could be implemented in a bit faster way.
+ Node split(Node n, bool connect = true)
+ {
+ return _split(n,connect);
+ }
+
+
///Class to make a snapshot of the graph and to restrore to it later.
///Class to make a snapshot of the graph and to restrore to it later.