# HG changeset patch # User deba # Date 1106926628 0 # Node ID 0a7d604a9763052085c89abfbea7757d4c9c7aa3 # Parent 6777f0b0e7b59260ca815f788d0906f2d0f8cb9f Concept modification to resolve the item by its ID. diff -r 6777f0b0e7b5 -r 0a7d604a9763 src/lemon/concept/graph_component.h --- a/src/lemon/concept/graph_component.h Fri Jan 28 15:19:34 2005 +0000 +++ b/src/lemon/concept/graph_component.h Fri Jan 28 15:37:08 2005 +0000 @@ -297,12 +297,26 @@ /// int id(const Node&) const { return -1;} - /// Gives back an unique integer id for the Edge. + /// \brief Gives back the node by the unique id. + /// + /// Gives back the node by the unique id. + /// If the graph does not contain node with the given id + /// then the result of the function is undetermined. + Node fromId(int id, Node) const { return INVALID;} + /// \brief Gives back an unique integer id for the Edge. + /// /// Gives back an unique integer id for the Edge. /// int id(const Edge&) const { return -1;} + /// \brief Gives back the edge by the unique id. + /// + /// Gives back the edge by the unique id. + /// If the graph does not contain edge with the given id + /// then the result of the function is undetermined. + Edge fromId(int id, Edge) const { return INVALID;} + template struct Constraints { @@ -311,9 +325,11 @@ typename _Graph::Node node; int nid = graph.id(node); nid = graph.id(node); + node = graph.fromId(nid, Node()); typename _Graph::Edge edge; int eid = graph.id(edge); eid = graph.id(edge); + edge = graph.fromId(eid, Edge()); } const _Graph& graph; diff -r 6777f0b0e7b5 -r 0a7d604a9763 src/lemon/full_graph.h --- a/src/lemon/full_graph.h Fri Jan 28 15:19:34 2005 +0000 +++ b/src/lemon/full_graph.h Fri Jan 28 15:37:08 2005 +0000 @@ -102,6 +102,10 @@ ///\return The ID of the edge \c e. static int id(Edge e) { return e.id; } + static Node fromId(int id, Node) { return Node(id);} + + static Edge fromId(int id, Edge) { return Edge(id);} + /// Finds an edge between two nodes. /// Finds an edge from node \c u to node \c v. diff -r 6777f0b0e7b5 -r 0a7d604a9763 src/lemon/list_graph.h --- a/src/lemon/list_graph.h Fri Jan 28 15:19:34 2005 +0000 +++ b/src/lemon/list_graph.h Fri Jan 28 15:37:08 2005 +0000 @@ -162,6 +162,9 @@ static int id(Node v) { return v.id; } static int id(Edge e) { return e.id; } + static Node fromId(int id, Node) { return Node(id);} + static Edge fromId(int id, Edge) { return Edge(id);} + /// Adds a new node to the graph. /// \warning It adds the new node to the front of the list. diff -r 6777f0b0e7b5 -r 0a7d604a9763 src/lemon/smart_graph.h --- a/src/lemon/smart_graph.h Fri Jan 28 15:19:34 2005 +0000 +++ b/src/lemon/smart_graph.h Fri Jan 28 15:37:08 2005 +0000 @@ -121,6 +121,10 @@ ///\return The ID of the edge \c e. static int id(Edge e) { return e.n; } + static Node fromId(int id, Node) { return Node(id);} + + static Edge fromId(int id, Edge) { return Edge(id);} + Node addNode() { Node n; n.n=nodes.size(); nodes.push_back(NodeT()); //FIXME: Hmmm...