lemon/euler.h
changeset 550 c5fd2d996909
parent 506 22f932bbb305
child 578 7c12061bd271
     1.1 --- a/lemon/euler.h	Thu Mar 05 10:13:20 2009 +0000
     1.2 +++ b/lemon/euler.h	Sun Mar 29 23:08:20 2009 +0200
     1.3 @@ -54,29 +54,29 @@
     1.4    ///\endcode
     1.5    ///If \c g is not Euler then the resulted tour will not be full or closed.
     1.6    ///\sa EulerIt
     1.7 -  template<class Digraph>
     1.8 +  template<typename GR>
     1.9    class DiEulerIt
    1.10    {
    1.11 -    typedef typename Digraph::Node Node;
    1.12 -    typedef typename Digraph::NodeIt NodeIt;
    1.13 -    typedef typename Digraph::Arc Arc;
    1.14 -    typedef typename Digraph::ArcIt ArcIt;
    1.15 -    typedef typename Digraph::OutArcIt OutArcIt;
    1.16 -    typedef typename Digraph::InArcIt InArcIt;
    1.17 +    typedef typename GR::Node Node;
    1.18 +    typedef typename GR::NodeIt NodeIt;
    1.19 +    typedef typename GR::Arc Arc;
    1.20 +    typedef typename GR::ArcIt ArcIt;
    1.21 +    typedef typename GR::OutArcIt OutArcIt;
    1.22 +    typedef typename GR::InArcIt InArcIt;
    1.23  
    1.24 -    const Digraph &g;
    1.25 -    typename Digraph::template NodeMap<OutArcIt> nedge;
    1.26 +    const GR &g;
    1.27 +    typename GR::template NodeMap<OutArcIt> nedge;
    1.28      std::list<Arc> euler;
    1.29  
    1.30    public:
    1.31  
    1.32      ///Constructor
    1.33  
    1.34 -    ///\param _g A digraph.
    1.35 +    ///\param gr A digraph.
    1.36      ///\param start The starting point of the tour. If it is not given
    1.37      ///       the tour will start from the first node.
    1.38 -    DiEulerIt(const Digraph &_g,typename Digraph::Node start=INVALID)
    1.39 -      : g(_g), nedge(g)
    1.40 +    DiEulerIt(const GR &gr, typename GR::Node start = INVALID)
    1.41 +      : g(gr), nedge(g)
    1.42      {
    1.43        if(start==INVALID) start=NodeIt(g);
    1.44        for(NodeIt n(g);n!=INVALID;++n) nedge[n]=OutArcIt(g,n);
    1.45 @@ -145,31 +145,31 @@
    1.46    ///
    1.47    ///If \c g is not Euler then the resulted tour will not be full or closed.
    1.48    ///\sa EulerIt
    1.49 -  template<class Digraph>
    1.50 +  template<typename GR>
    1.51    class EulerIt
    1.52    {
    1.53 -    typedef typename Digraph::Node Node;
    1.54 -    typedef typename Digraph::NodeIt NodeIt;
    1.55 -    typedef typename Digraph::Arc Arc;
    1.56 -    typedef typename Digraph::Edge Edge;
    1.57 -    typedef typename Digraph::ArcIt ArcIt;
    1.58 -    typedef typename Digraph::OutArcIt OutArcIt;
    1.59 -    typedef typename Digraph::InArcIt InArcIt;
    1.60 +    typedef typename GR::Node Node;
    1.61 +    typedef typename GR::NodeIt NodeIt;
    1.62 +    typedef typename GR::Arc Arc;
    1.63 +    typedef typename GR::Edge Edge;
    1.64 +    typedef typename GR::ArcIt ArcIt;
    1.65 +    typedef typename GR::OutArcIt OutArcIt;
    1.66 +    typedef typename GR::InArcIt InArcIt;
    1.67  
    1.68 -    const Digraph &g;
    1.69 -    typename Digraph::template NodeMap<OutArcIt> nedge;
    1.70 -    typename Digraph::template EdgeMap<bool> visited;
    1.71 +    const GR &g;
    1.72 +    typename GR::template NodeMap<OutArcIt> nedge;
    1.73 +    typename GR::template EdgeMap<bool> visited;
    1.74      std::list<Arc> euler;
    1.75  
    1.76    public:
    1.77  
    1.78      ///Constructor
    1.79  
    1.80 -    ///\param _g An graph.
    1.81 +    ///\param gr An graph.
    1.82      ///\param start The starting point of the tour. If it is not given
    1.83      ///       the tour will start from the first node.
    1.84 -    EulerIt(const Digraph &_g,typename Digraph::Node start=INVALID)
    1.85 -      : g(_g), nedge(g), visited(g,false)
    1.86 +    EulerIt(const GR &gr, typename GR::Node start = INVALID)
    1.87 +      : g(gr), nedge(g), visited(g, false)
    1.88      {
    1.89        if(start==INVALID) start=NodeIt(g);
    1.90        for(NodeIt n(g);n!=INVALID;++n) nedge[n]=OutArcIt(g,n);
    1.91 @@ -238,25 +238,25 @@
    1.92    ///and only if it is connected and the number of incident arcs is even
    1.93    ///for each node. <em>Therefore, there are digraphs which are not Eulerian,
    1.94    ///but still have an Euler tour</em>.
    1.95 -  template<class Digraph>
    1.96 +  template<typename GR>
    1.97  #ifdef DOXYGEN
    1.98    bool
    1.99  #else
   1.100 -  typename enable_if<UndirectedTagIndicator<Digraph>,bool>::type
   1.101 -  eulerian(const Digraph &g)
   1.102 +  typename enable_if<UndirectedTagIndicator<GR>,bool>::type
   1.103 +  eulerian(const GR &g)
   1.104    {
   1.105 -    for(typename Digraph::NodeIt n(g);n!=INVALID;++n)
   1.106 +    for(typename GR::NodeIt n(g);n!=INVALID;++n)
   1.107        if(countIncEdges(g,n)%2) return false;
   1.108      return connected(g);
   1.109    }
   1.110 -  template<class Digraph>
   1.111 -  typename disable_if<UndirectedTagIndicator<Digraph>,bool>::type
   1.112 +  template<class GR>
   1.113 +  typename disable_if<UndirectedTagIndicator<GR>,bool>::type
   1.114  #endif
   1.115 -  eulerian(const Digraph &g)
   1.116 +  eulerian(const GR &g)
   1.117    {
   1.118 -    for(typename Digraph::NodeIt n(g);n!=INVALID;++n)
   1.119 +    for(typename GR::NodeIt n(g);n!=INVALID;++n)
   1.120        if(countInArcs(g,n)!=countOutArcs(g,n)) return false;
   1.121 -    return connected(Undirector<const Digraph>(g));
   1.122 +    return connected(Undirector<const GR>(g));
   1.123    }
   1.124  
   1.125  }