findEdge() declaration went to the right place (for the sake of Doxygen.)
authoralpar
Mon, 08 Nov 2004 15:24:53 +0000
changeset 9690631847b37e5
parent 968 1a7593db0eaa
child 970 09f9abe22df2
findEdge() declaration went to the right place (for the sake of Doxygen.)
src/lemon/smart_graph.h
     1.1 --- a/src/lemon/smart_graph.h	Mon Nov 08 15:23:31 2004 +0000
     1.2 +++ b/src/lemon/smart_graph.h	Mon Nov 08 15:24:53 2004 +0000
     1.3 @@ -45,6 +45,10 @@
     1.4    /// \addtogroup graphs
     1.5    /// @{
     1.6  
     1.7 +  ///Base of SmartGraph
     1.8 +
     1.9 +  ///Base of SmartGraph
    1.10 +  ///
    1.11    class SmartGraphBase {
    1.12  
    1.13      struct NodeT 
    1.14 @@ -131,22 +135,6 @@
    1.15        return e;
    1.16      }
    1.17  
    1.18 -    /// Finds an edge between two nodes.
    1.19 -
    1.20 -    /// Finds an edge from node \c u to node \c v.
    1.21 -    ///
    1.22 -    /// If \c prev is \ref INVALID (this is the default value), then
    1.23 -    /// It finds the first edge from \c u to \c v. Otherwise it looks for
    1.24 -    /// the next edge from \c u to \c v after \c prev.
    1.25 -    /// \return The found edge or INVALID if there is no such an edge.
    1.26 -    Edge findEdge(Node u,Node v, Edge prev = INVALID) 
    1.27 -    {
    1.28 -      int e = (prev.n==-1)? nodes[u.n].first_out : edges[prev.n].next_out;
    1.29 -      while(e!=-1 && edges[e].tail!=v.n) e = edges[e].next_out;
    1.30 -      prev.n=e;
    1.31 -      return prev;
    1.32 -    }
    1.33 -    
    1.34      void clear() {
    1.35        edges.clear();
    1.36        nodes.clear();
    1.37 @@ -214,6 +202,13 @@
    1.38        edge.n = edges[edge.n].next_in;
    1.39      }
    1.40  
    1.41 +    Edge _findEdge(Node u,Node v, Edge prev = INVALID) 
    1.42 +    {
    1.43 +      int e = (prev.n==-1)? nodes[u.n].first_out : edges[prev.n].next_out;
    1.44 +      while(e!=-1 && edges[e].tail!=v.n) e = edges[e].next_out;
    1.45 +      prev.n=e;
    1.46 +      return prev;
    1.47 +    }
    1.48    };
    1.49  
    1.50    typedef AlterableGraphExtender<SmartGraphBase> AlterableSmartGraphBase;
    1.51 @@ -242,7 +237,29 @@
    1.52    ///Of course it should be used as a stack. (Maybe X is not necessary.)
    1.53    ///
    1.54    ///\author Alpar Juttner
    1.55 -  class SmartGraph :public ClearableSmartGraphBase { };
    1.56 +  class SmartGraph :public ClearableSmartGraphBase {
    1.57 +  public:
    1.58 +    /// Finds an edge between two nodes.
    1.59 +
    1.60 +    /// Finds an edge from node \c u to node \c v.
    1.61 +    ///
    1.62 +    /// If \c prev is \ref INVALID (this is the default value), then
    1.63 +    /// it finds the first edge from \c u to \c v. Otherwise it looks for
    1.64 +    /// the next edge from \c u to \c v after \c prev.
    1.65 +    /// \return The found edge or \ref INVALID if there is no such an edge.
    1.66 +    ///
    1.67 +    /// Thus you can iterate through each edge from \c u to \c v as it follows.
    1.68 +    /// \code
    1.69 +    /// for(Edge e=G.findEdge(u,v);e!=INVALID;e=G.findEdge(u,v,e)) {
    1.70 +    ///   ...
    1.71 +    /// }
    1.72 +    /// \endcode
    1.73 +    /// \todo Possibly it should be a global function.
    1.74 +    Edge findEdge(Node u,Node v, Edge prev = INVALID) 
    1.75 +    {
    1.76 +      return _findEdge(u,v,prev);
    1.77 +    }
    1.78 +};
    1.79    
    1.80    template <>
    1.81    int countNodes<SmartGraph>(const SmartGraph& graph) {