1.1 --- a/src/lemon/graph_utils.h Mon Nov 08 08:40:37 2004 +0000
1.2 +++ b/src/lemon/graph_utils.h Mon Nov 08 15:22:39 2004 +0000
1.3 @@ -90,6 +90,36 @@
1.4 }
1.5 return num;
1.6 }
1.7 +
1.8 + /// Finds an edge between two nodes of a graph.
1.9 +
1.10 + /// Finds an edge from node \c u to node \c v in graph \c g.
1.11 + ///
1.12 + /// If \c prev is \ref INVALID (this is the default value), then
1.13 + /// it finds the first edge from \c u to \c v. Otherwise it looks for
1.14 + /// the next edge from \c u to \c v after \c prev.
1.15 + /// \return The found edge or \ref INVALID if there is no such an edge.
1.16 + ///
1.17 + /// Thus you can iterate through each edge from \c u to \c v as it follows.
1.18 + /// \code
1.19 + /// for(Edge e=findEdge(g,u,v);e!=INVALID;e=findEdge(g,u,v,e)) {
1.20 + /// ...
1.21 + /// }
1.22 + /// \endcode
1.23 + /// \todo We may want to use the \ref concept::GraphBase "GraphBase"
1.24 + /// interface here...
1.25 + /// \bug Untested ...
1.26 + template <typename Graph>
1.27 + typename Graph::Edge findEdge(const Graph &g,
1.28 + typename Graph::Node u, typename Graph::Node v,
1.29 + typename Graph::Edge prev = INVALID)
1.30 + {
1.31 + typename Graph::OutEdgeIt e(g,prev);
1.32 + if(prev==INVALID) g.first(e,u);
1.33 + else ++e;
1.34 + while(e!=INVALID && g.tail(e)!=v) ++e;
1.35 + return e;
1.36 + }
1.37
1.38 ///\e
1.39