src/lemon/graph_utils.h
changeset 1267 a93f94dbe3d3
parent 1192 aa4483befa56
child 1359 1581f961cfaa
     1.1 --- a/src/lemon/graph_utils.h	Fri Mar 25 22:11:28 2005 +0000
     1.2 +++ b/src/lemon/graph_utils.h	Fri Mar 25 23:31:57 2005 +0000
     1.3 @@ -21,7 +21,6 @@
     1.4  
     1.5  #include <lemon/invalid.h>
     1.6  #include <lemon/utility.h>
     1.7 -#include <lemon/map_utils.h>
     1.8  
     1.9  ///\ingroup gutils
    1.10  ///\file
    1.11 @@ -34,8 +33,8 @@
    1.12  
    1.13  namespace lemon {
    1.14  
    1.15 -/// \addtogroup gutils
    1.16 -/// @{
    1.17 +  /// \addtogroup gutils
    1.18 +  /// @{
    1.19  
    1.20    /// \brief Function to count the items in the graph.
    1.21    ///
    1.22 @@ -160,8 +159,8 @@
    1.23    /// \bug Untested ...
    1.24    template <typename Graph>
    1.25    typename Graph::Edge findEdge(const Graph &g,
    1.26 -		typename Graph::Node u, typename Graph::Node v,
    1.27 -		typename Graph::Edge prev = INVALID) 
    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 @@ -225,46 +224,51 @@
    1.34      edgeCopy(_d, _s, _nb, _eb);
    1.35    }
    1.36   
    1.37 -   template <
    1.38 +  template <
    1.39      typename _DestinationGraph, 
    1.40      typename _SourceGraph, 
    1.41      typename _NodeBijection 
    1.42      =typename _SourceGraph::template NodeMap<typename _DestinationGraph::Node>,
    1.43      typename _EdgeBijection 
    1.44 -    =typename _SourceGraph::template EdgeMap<typename _DestinationGraph::Edge>
    1.45 -   >
    1.46 -   class GraphCopy {
    1.47 -   public:
    1.48 +    = typename _SourceGraph::template EdgeMap<typename _DestinationGraph::Edge>
    1.49 +  >
    1.50 +  class GraphCopy {
    1.51 +  public:
    1.52 +    
    1.53 +    typedef _DestinationGraph DestinationGraph;
    1.54 +    typedef _SourceGraph SourceGraph;
    1.55  
    1.56 -     typedef _DestinationGraph DestinationGraph;
    1.57 -     typedef _SourceGraph SourceGraph;
    1.58 +    typedef _NodeBijection NodeBijection;
    1.59 +    typedef _EdgeBijection EdgeBijection;
    1.60 +    
    1.61 +  protected:          
    1.62 +    
    1.63 +    NodeBijection node_bijection;
    1.64 +    EdgeBijection edge_bijection;     
    1.65  
    1.66 -     typedef _NodeBijection NodeBijection;
    1.67 -     typedef _EdgeBijection EdgeBijection;
    1.68 +  public:
    1.69 +     
    1.70 +    GraphCopy(DestinationGraph& _d, const SourceGraph& _s) {
    1.71 +      copyGraph(_d, _s, node_bijection, edge_bijection);
    1.72 +    }
    1.73 +    
    1.74 +    const NodeBijection& getNodeBijection() const {
    1.75 +      return node_bijection;
    1.76 +    }
    1.77  
    1.78 -   protected:          
    1.79 +    const EdgeBijection& getEdgeBijection() const {
    1.80 +      return edge_bijection;
    1.81 +    }
    1.82 +     
    1.83 +  };
    1.84  
    1.85 -     NodeBijection node_bijection;
    1.86 -     EdgeBijection edge_bijection;     
    1.87  
    1.88 -   public:
    1.89 -     
    1.90 -     GraphCopy(DestinationGraph& _d, const SourceGraph& _s) {
    1.91 -       copyGraph(_d, _s, node_bijection, edge_bijection);
    1.92 -     }
    1.93 -
    1.94 -     const NodeBijection& getNodeBijection() const {
    1.95 -       return node_bijection;
    1.96 -     }
    1.97 -
    1.98 -     const EdgeBijection& getEdgeBijection() const {
    1.99 -       return edge_bijection;
   1.100 -     }
   1.101 -     
   1.102 -   };
   1.103 +  template <typename _Graph, typename _Item>
   1.104 +  class ItemSetTraits {
   1.105 +  };
   1.106    
   1.107    template <typename _Graph>
   1.108 -  class GraphNodeSet {
   1.109 +  class ItemSetTraits<_Graph, typename _Graph::Node> {
   1.110    public:
   1.111      
   1.112      typedef _Graph Graph;
   1.113 @@ -283,14 +287,10 @@
   1.114  	: Parent(_graph, _value) {}
   1.115      };
   1.116  
   1.117 -    typedef IdMap<Graph, Item> IdMap;
   1.118 -    
   1.119 -  private:
   1.120 -    Graph* graph;
   1.121    };
   1.122  
   1.123    template <typename _Graph>
   1.124 -  class GraphEdgeSet {
   1.125 +  class ItemSetTraits<_Graph, typename _Graph::Edge> {
   1.126    public:
   1.127      
   1.128      typedef _Graph Graph;
   1.129 @@ -309,12 +309,29 @@
   1.130  	: Parent(_graph, _value) {}
   1.131      };
   1.132  
   1.133 -    typedef IdMap<Graph, Item> IdMap;
   1.134 -    
   1.135 -  private:
   1.136 -    Graph* graph;
   1.137    };
   1.138  
   1.139 +  template <typename _Graph>
   1.140 +  class ItemSetTraits<_Graph, typename _Graph::UndirEdge> {
   1.141 +  public:
   1.142 +    
   1.143 +    typedef _Graph Graph;
   1.144 +
   1.145 +    typedef typename Graph::UndirEdge Item;
   1.146 +    typedef typename Graph::UndirEdgeIt ItemIt;
   1.147 +
   1.148 +    template <typename _Value>
   1.149 +    class Map : public Graph::template UndirEdgeMap<_Value> {
   1.150 +    public:
   1.151 +      typedef typename Graph::template UndirEdgeMap<_Value> Parent; 
   1.152 +      typedef typename Parent::Value Value;
   1.153 +
   1.154 +      Map(const Graph& _graph) : Parent(_graph) {}
   1.155 +      Map(const Graph& _graph, const Value& _value) 
   1.156 +	: Parent(_graph, _value) {}
   1.157 +    };
   1.158 +
   1.159 +  };
   1.160  
   1.161    /// @}
   1.162