Concept modification to resolve the item by its ID.
1.1 --- a/src/lemon/concept/graph_component.h Fri Jan 28 15:19:34 2005 +0000
1.2 +++ b/src/lemon/concept/graph_component.h Fri Jan 28 15:37:08 2005 +0000
1.3 @@ -297,12 +297,26 @@
1.4 ///
1.5 int id(const Node&) const { return -1;}
1.6
1.7 - /// Gives back an unique integer id for the Edge.
1.8 + /// \brief Gives back the node by the unique id.
1.9 + ///
1.10 + /// Gives back the node by the unique id.
1.11 + /// If the graph does not contain node with the given id
1.12 + /// then the result of the function is undetermined.
1.13 + Node fromId(int id, Node) const { return INVALID;}
1.14
1.15 + /// \brief Gives back an unique integer id for the Edge.
1.16 + ///
1.17 /// Gives back an unique integer id for the Edge.
1.18 ///
1.19 int id(const Edge&) const { return -1;}
1.20
1.21 + /// \brief Gives back the edge by the unique id.
1.22 + ///
1.23 + /// Gives back the edge by the unique id.
1.24 + /// If the graph does not contain edge with the given id
1.25 + /// then the result of the function is undetermined.
1.26 + Edge fromId(int id, Edge) const { return INVALID;}
1.27 +
1.28 template <typename _Graph>
1.29 struct Constraints {
1.30
1.31 @@ -311,9 +325,11 @@
1.32 typename _Graph::Node node;
1.33 int nid = graph.id(node);
1.34 nid = graph.id(node);
1.35 + node = graph.fromId(nid, Node());
1.36 typename _Graph::Edge edge;
1.37 int eid = graph.id(edge);
1.38 eid = graph.id(edge);
1.39 + edge = graph.fromId(eid, Edge());
1.40 }
1.41
1.42 const _Graph& graph;
2.1 --- a/src/lemon/full_graph.h Fri Jan 28 15:19:34 2005 +0000
2.2 +++ b/src/lemon/full_graph.h Fri Jan 28 15:37:08 2005 +0000
2.3 @@ -102,6 +102,10 @@
2.4 ///\return The ID of the edge \c e.
2.5 static int id(Edge e) { return e.id; }
2.6
2.7 + static Node fromId(int id, Node) { return Node(id);}
2.8 +
2.9 + static Edge fromId(int id, Edge) { return Edge(id);}
2.10 +
2.11 /// Finds an edge between two nodes.
2.12
2.13 /// Finds an edge from node \c u to node \c v.
3.1 --- a/src/lemon/list_graph.h Fri Jan 28 15:19:34 2005 +0000
3.2 +++ b/src/lemon/list_graph.h Fri Jan 28 15:37:08 2005 +0000
3.3 @@ -162,6 +162,9 @@
3.4 static int id(Node v) { return v.id; }
3.5 static int id(Edge e) { return e.id; }
3.6
3.7 + static Node fromId(int id, Node) { return Node(id);}
3.8 + static Edge fromId(int id, Edge) { return Edge(id);}
3.9 +
3.10 /// Adds a new node to the graph.
3.11
3.12 /// \warning It adds the new node to the front of the list.
4.1 --- a/src/lemon/smart_graph.h Fri Jan 28 15:19:34 2005 +0000
4.2 +++ b/src/lemon/smart_graph.h Fri Jan 28 15:37:08 2005 +0000
4.3 @@ -121,6 +121,10 @@
4.4 ///\return The ID of the edge \c e.
4.5 static int id(Edge e) { return e.n; }
4.6
4.7 + static Node fromId(int id, Node) { return Node(id);}
4.8 +
4.9 + static Edge fromId(int id, Edge) { return Edge(id);}
4.10 +
4.11 Node addNode() {
4.12 Node n; n.n=nodes.size();
4.13 nodes.push_back(NodeT()); //FIXME: Hmmm...