lemon/graph_adaptor.h
changeset 1981 81c8efe92706
parent 1979 c2992fd74dad
child 1989 d276e88aa48a
equal deleted inserted replaced
24:fcab6cb02993 25:da7973414ebf
   696       Parent::setEdgeFilterMap(_edge_filter_map);
   696       Parent::setEdgeFilterMap(_edge_filter_map);
   697     }
   697     }
   698   };
   698   };
   699 
   699 
   700   template <typename _Graph>
   700   template <typename _Graph>
   701   class UndirectGraphAdaptorBase : 
   701   class UndirGraphAdaptorBase : 
   702     public UGraphBaseExtender<GraphAdaptorBase<_Graph> > {
   702     public UGraphBaseExtender<GraphAdaptorBase<_Graph> > {
   703   public:
   703   public:
   704     typedef _Graph Graph;
   704     typedef _Graph Graph;
   705     typedef UGraphBaseExtender<GraphAdaptorBase<_Graph> > Parent;
   705     typedef UGraphBaseExtender<GraphAdaptorBase<_Graph> > Parent;
   706   protected:
   706   protected:
   707     UndirectGraphAdaptorBase() : Parent() { }
   707     UndirGraphAdaptorBase() : Parent() { }
   708   public:
   708   public:
   709     typedef typename Parent::UEdge UEdge;
   709     typedef typename Parent::UEdge UEdge;
   710     typedef typename Parent::Edge Edge;
   710     typedef typename Parent::Edge Edge;
   711     
   711     
   712     template <typename T>
   712     template <typename T>
   713     class EdgeMap {
   713     class EdgeMap {
   714     protected:
   714     protected:
   715       const UndirectGraphAdaptorBase<_Graph>* g;
   715       const UndirGraphAdaptorBase<_Graph>* g;
   716       template <typename TT> friend class EdgeMap;
   716       template <typename TT> friend class EdgeMap;
   717       typename _Graph::template EdgeMap<T> forward_map, backward_map; 
   717       typename _Graph::template EdgeMap<T> forward_map, backward_map; 
   718     public:
   718     public:
   719       typedef T Value;
   719       typedef T Value;
   720       typedef Edge Key;
   720       typedef Edge Key;
   721       
   721       
   722       EdgeMap(const UndirectGraphAdaptorBase<_Graph>& _g) : g(&_g), 
   722       EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g) : g(&_g), 
   723 	forward_map(*(g->graph)), backward_map(*(g->graph)) { }
   723 	forward_map(*(g->graph)), backward_map(*(g->graph)) { }
   724 
   724 
   725       EdgeMap(const UndirectGraphAdaptorBase<_Graph>& _g, T a) : g(&_g), 
   725       EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g, T a) : g(&_g), 
   726 	forward_map(*(g->graph), a), backward_map(*(g->graph), a) { }
   726 	forward_map(*(g->graph), a), backward_map(*(g->graph), a) { }
   727       
   727       
   728       void set(Edge e, T a) { 
   728       void set(Edge e, T a) { 
   729 	if (g->direction(e)) 
   729 	if (g->direction(e)) 
   730 	  forward_map.set(e, a); 
   730 	  forward_map.set(e, a); 
   746       typename _Graph::template EdgeMap<T> map; 
   746       typename _Graph::template EdgeMap<T> map; 
   747     public:
   747     public:
   748       typedef T Value;
   748       typedef T Value;
   749       typedef UEdge Key;
   749       typedef UEdge Key;
   750       
   750       
   751       UEdgeMap(const UndirectGraphAdaptorBase<_Graph>& g) : 
   751       UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g) : 
   752 	map(*(g.graph)) { }
   752 	map(*(g.graph)) { }
   753 
   753 
   754       UEdgeMap(const UndirectGraphAdaptorBase<_Graph>& g, T a) : 
   754       UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g, T a) : 
   755 	map(*(g.graph), a) { }
   755 	map(*(g.graph), a) { }
   756       
   756       
   757       void set(UEdge e, T a) { 
   757       void set(UEdge e, T a) { 
   758 	map.set(e, a); 
   758 	map.set(e, a); 
   759       }
   759       }
   771   /// Undocumented, untested!!!
   771   /// Undocumented, untested!!!
   772   /// If somebody knows nice demo application, let's polulate it.
   772   /// If somebody knows nice demo application, let's polulate it.
   773   /// 
   773   /// 
   774   /// \author Marton Makai
   774   /// \author Marton Makai
   775   template<typename _Graph>
   775   template<typename _Graph>
   776   class UndirectGraphAdaptor : 
   776   class UndirGraphAdaptor : 
   777     public UGraphAdaptorExtender<
   777     public UGraphAdaptorExtender<
   778     UndirectGraphAdaptorBase<_Graph> > {
   778     UndirGraphAdaptorBase<_Graph> > {
   779   public:
   779   public:
   780     typedef _Graph Graph;
   780     typedef _Graph Graph;
   781     typedef UGraphAdaptorExtender<
   781     typedef UGraphAdaptorExtender<
   782       UndirectGraphAdaptorBase<_Graph> > Parent;
   782       UndirGraphAdaptorBase<_Graph> > Parent;
   783   protected:
   783   protected:
   784     UndirectGraphAdaptor() { }
   784     UndirGraphAdaptor() { }
   785   public:
   785   public:
   786     UndirectGraphAdaptor(_Graph& _graph) { 
   786     UndirGraphAdaptor(_Graph& _graph) { 
   787       setGraph(_graph);
   787       setGraph(_graph);
   788     }
   788     }
   789   };
   789   };
   790 
   790 
   791   
   791