# HG changeset patch # User alpar # Date 1099927493 0 # Node ID 0631847b37e5a7965ed4aeceb5a2144e4c8b5e82 # Parent 1a7593db0eaacaa83a00d6e7204ac9101738aeef findEdge() declaration went to the right place (for the sake of Doxygen.) diff -r 1a7593db0eaa -r 0631847b37e5 src/lemon/smart_graph.h --- a/src/lemon/smart_graph.h Mon Nov 08 15:23:31 2004 +0000 +++ b/src/lemon/smart_graph.h Mon Nov 08 15:24:53 2004 +0000 @@ -45,6 +45,10 @@ /// \addtogroup graphs /// @{ + ///Base of SmartGraph + + ///Base of SmartGraph + /// class SmartGraphBase { struct NodeT @@ -131,22 +135,6 @@ return e; } - /// Finds an edge between two nodes. - - /// Finds an edge from node \c u to node \c v. - /// - /// If \c prev is \ref INVALID (this is the default value), then - /// It finds the first edge from \c u to \c v. Otherwise it looks for - /// the next edge from \c u to \c v after \c prev. - /// \return The found edge or INVALID if there is no such an edge. - Edge findEdge(Node u,Node v, Edge prev = INVALID) - { - int e = (prev.n==-1)? nodes[u.n].first_out : edges[prev.n].next_out; - while(e!=-1 && edges[e].tail!=v.n) e = edges[e].next_out; - prev.n=e; - return prev; - } - void clear() { edges.clear(); nodes.clear(); @@ -214,6 +202,13 @@ edge.n = edges[edge.n].next_in; } + Edge _findEdge(Node u,Node v, Edge prev = INVALID) + { + int e = (prev.n==-1)? nodes[u.n].first_out : edges[prev.n].next_out; + while(e!=-1 && edges[e].tail!=v.n) e = edges[e].next_out; + prev.n=e; + return prev; + } }; typedef AlterableGraphExtender AlterableSmartGraphBase; @@ -242,7 +237,29 @@ ///Of course it should be used as a stack. (Maybe X is not necessary.) /// ///\author Alpar Juttner - class SmartGraph :public ClearableSmartGraphBase { }; + class SmartGraph :public ClearableSmartGraphBase { + public: + /// Finds an edge between two nodes. + + /// Finds an edge from node \c u to node \c v. + /// + /// If \c prev is \ref INVALID (this is the default value), then + /// it finds the first edge from \c u to \c v. Otherwise it looks for + /// the next edge from \c u to \c v after \c prev. + /// \return The found edge or \ref INVALID if there is no such an edge. + /// + /// Thus you can iterate through each edge from \c u to \c v as it follows. + /// \code + /// for(Edge e=G.findEdge(u,v);e!=INVALID;e=G.findEdge(u,v,e)) { + /// ... + /// } + /// \endcode + /// \todo Possibly it should be a global function. + Edge findEdge(Node u,Node v, Edge prev = INVALID) + { + return _findEdge(u,v,prev); + } +}; template <> int countNodes(const SmartGraph& graph) {