src/hugo/graph_wrapper.h
changeset 783 81bf2d766164
parent 775 e46a1f0623a0
child 792 147eb3a58706
equal deleted inserted replaced
27:695864a89e4d 28:5f5edb1e7ae5
   179       //EdgeIt(const EdgeIt& e) : Edge(e), gw(e.gw) { }
   179       //EdgeIt(const EdgeIt& e) : Edge(e), gw(e.gw) { }
   180       EdgeIt(Invalid i) : Edge(i) { }
   180       EdgeIt(Invalid i) : Edge(i) { }
   181       EdgeIt(const GraphWrapper<Graph>& _gw) : 
   181       EdgeIt(const GraphWrapper<Graph>& _gw) : 
   182 	Edge(typename Graph::EdgeIt(*(_gw.graph))), gw(&_gw) { }
   182 	Edge(typename Graph::EdgeIt(*(_gw.graph))), gw(&_gw) { }
   183       EdgeIt(const GraphWrapper<Graph>& _gw, const Edge& e) : 
   183       EdgeIt(const GraphWrapper<Graph>& _gw, const Edge& e) : 
   184 	Edge(w), gw(&_gw) { }
   184 	Edge(e), gw(&_gw) { }
   185       EdgeIt& operator++() { 
   185       EdgeIt& operator++() { 
   186 	*(static_cast<Edge*>(this))=
   186 	*(static_cast<Edge*>(this))=
   187 	  ++(typename Graph::EdgeIt(*(gw->graph), *this));
   187 	  ++(typename Graph::EdgeIt(*(gw->graph), *this));
   188 	return *this; 
   188 	return *this; 
   189       }
   189       }
   426     public:
   426     public:
   427       OutEdgeIt() { }
   427       OutEdgeIt() { }
   428       //      OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { }
   428       //      OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { }
   429       OutEdgeIt(Invalid i) : Edge(i) { }
   429       OutEdgeIt(Invalid i) : Edge(i) { }
   430       OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : 
   430       OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : 
   431 	Edge(typename Graph::OutEdgeIt(*(_gw.graph)), n), gw(&_gw) { }
   431 	Edge(typename Graph::OutEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
   432       OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
   432       OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
   433 	     const Edge& e) : 
   433 	     const Edge& e) : 
   434 	Edge(e), gw(&_gw) { }
   434 	Edge(e), gw(&_gw) { }
   435       OutEdgeIt& operator++() { 
   435       OutEdgeIt& operator++() { 
   436 	*(static_cast<Edge*>(this))=
   436 	*(static_cast<Edge*>(this))=
   448     public:
   448     public:
   449       InEdgeIt() { }
   449       InEdgeIt() { }
   450       //      InEdgeIt(const InEdgeIt& e) : Edge(e), gw(e.gw) { }
   450       //      InEdgeIt(const InEdgeIt& e) : Edge(e), gw(e.gw) { }
   451       InEdgeIt(Invalid i) : Edge(i) { }
   451       InEdgeIt(Invalid i) : Edge(i) { }
   452       InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : 
   452       InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, const Node& n) : 
   453 	Edge(typename Graph::InEdgeIt(*(_gw.graph)), n), gw(&_gw) { }
   453 	Edge(typename Graph::InEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
   454       InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
   454       InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _gw, 
   455 	     const Edge& e) : 
   455 	     const Edge& e) : 
   456 	Edge(e), gw(&_gw) { }
   456 	Edge(e), gw(&_gw) { }
   457       InEdgeIt& operator++() { 
   457       InEdgeIt& operator++() { 
   458 	*(static_cast<Edge*>(this))=
   458 	*(static_cast<Edge*>(this))=
  2038 //       NodeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) : 
  2038 //       NodeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) : 
  2039 // 	n(*(_G.graph)) { }
  2039 // 	n(*(_G.graph)) { }
  2040 //       operator Node() const { return Node(typename Graph::Node(n)); }
  2040 //       operator Node() const { return Node(typename Graph::Node(n)); }
  2041 //     };
  2041 //     };
  2042     typedef typename GraphWrapper<Graph>::Edge Edge;
  2042     typedef typename GraphWrapper<Graph>::Edge Edge;
  2043     class OutEdgeIt { 
  2043     class OutEdgeIt : public Edge { 
  2044       friend class GraphWrapper<Graph>;
  2044       friend class GraphWrapper<Graph>;
  2045       friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
  2045       friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
  2046 //      typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
  2046       const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>* gw;
  2047       typename Graph::OutEdgeIt e;
       
  2048     public:
  2047     public:
  2049       OutEdgeIt() { }
  2048       OutEdgeIt() { }
  2050       OutEdgeIt(const typename Graph::OutEdgeIt& _e) : e(_e) { }
  2049       //OutEdgeIt(const OutEdgeIt& e) : Edge(e), gw(e.gw) { }
  2051       OutEdgeIt(const Invalid& i) : e(i) { }
  2050       OutEdgeIt(Invalid i) : Edge(i) { }
  2052       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G, 
  2051       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
  2053 		const Node& _n) : 
  2052 		const Node& n) : 
  2054 	e((*_G.first_out_edges)[_n]) { }
  2053 	Edge((*(_gw.first_out_edges))[n]), gw(&_gw) { }
  2055       operator Edge() const { return Edge(typename Graph::Edge(e)); }
  2054       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
  2056     };
  2055 		const Edge& e) : 
  2057     class InEdgeIt { 
  2056 	Edge(e), gw(&_gw) { }
  2058       friend class GraphWrapper<Graph>;
  2057       OutEdgeIt& operator++() { 
  2059       friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
  2058 	*(static_cast<Edge*>(this))=
  2060 //      typedef typename Graph::InEdgeIt GraphInEdgeIt;
  2059 	  ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
  2061       typename Graph::InEdgeIt e;
  2060 	return *this; 
  2062     public:
  2061       }
  2063       InEdgeIt() { }
  2062     };
  2064       InEdgeIt(const typename Graph::InEdgeIt& _e) : e(_e) { }
  2063 //     class InEdgeIt { 
  2065       InEdgeIt(const Invalid& i) : e(i) { }
  2064 //       friend class GraphWrapper<Graph>;
  2066       InEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G, 
  2065 //       friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
  2067 	       const Node& _n) : 
  2066 // //      typedef typename Graph::InEdgeIt GraphInEdgeIt;
  2068 	e(*(_G.graph), typename Graph::Node(_n)) { }
  2067 //       typename Graph::InEdgeIt e;
  2069       operator Edge() const { return Edge(typename Graph::Edge(e)); }
  2068 //     public:
  2070     };
  2069 //       InEdgeIt() { }
       
  2070 //       InEdgeIt(const typename Graph::InEdgeIt& _e) : e(_e) { }
       
  2071 //       InEdgeIt(const Invalid& i) : e(i) { }
       
  2072 //       InEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G, 
       
  2073 // 	       const Node& _n) : 
       
  2074 // 	e(*(_G.graph), typename Graph::Node(_n)) { }
       
  2075 //       operator Edge() const { return Edge(typename Graph::Edge(e)); }
       
  2076 //     };	
  2071     //typedef typename Graph::SymEdgeIt SymEdgeIt;
  2077     //typedef typename Graph::SymEdgeIt SymEdgeIt;
  2072     class EdgeIt { 
  2078 //     class EdgeIt { 
  2073       friend class GraphWrapper<Graph>;
  2079 //       friend class GraphWrapper<Graph>;
  2074       friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
  2080 //       friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
  2075 //      typedef typename Graph::EdgeIt GraphEdgeIt;
  2081 // //      typedef typename Graph::EdgeIt GraphEdgeIt;
  2076       typename Graph::EdgeIt e;
  2082 //       typename Graph::EdgeIt e;
  2077     public:
  2083 //     public:
  2078       EdgeIt() { }
  2084 //       EdgeIt() { }
  2079       EdgeIt(const typename Graph::EdgeIt& _e) : e(_e) { }
  2085 //       EdgeIt(const typename Graph::EdgeIt& _e) : e(_e) { }
  2080       EdgeIt(const Invalid& i) : e(i) { }
  2086 //       EdgeIt(const Invalid& i) : e(i) { }
  2081       EdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) : 
  2087 //       EdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) : 
  2082 	e(*(_G.graph)) { }
  2088 // 	e(*(_G.graph)) { }
  2083       operator Edge() const { return Edge(typename Graph::Edge(e)); }
  2089 //       operator Edge() const { return Edge(typename Graph::Edge(e)); }
  2084     };
  2090 //     };
  2085 
  2091 
  2086     using GraphWrapper<Graph>::first;
  2092     using GraphWrapper<Graph>::first;
  2087 //     NodeIt& first(NodeIt& i) const { 
  2093 //     NodeIt& first(NodeIt& i) const { 
  2088 //       i=NodeIt(*this); return i;
  2094 //       i=NodeIt(*this); return i;
  2089 //     }
  2095 //     }
  2090     OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
  2096     OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
  2091       i=OutEdgeIt(*this, p); return i;
  2097       i=OutEdgeIt(*this, p); return i;
  2092     }
  2098     }
  2093     InEdgeIt& first(InEdgeIt& i, const Node& p) const { 
  2099 //     InEdgeIt& first(InEdgeIt& i, const Node& p) const { 
  2094       i=InEdgeIt(*this, p); return i;
  2100 //       i=InEdgeIt(*this, p); return i;
  2095     }
  2101 //     }
  2096     EdgeIt& first(EdgeIt& i) const { 
  2102 //     EdgeIt& first(EdgeIt& i) const { 
  2097       i=EdgeIt(*this); return i;
  2103 //       i=EdgeIt(*this); return i;
  2098     }
  2104 //     }
  2099 
  2105 
  2100     using GraphWrapper<Graph>::next;
  2106 //     using GraphWrapper<Graph>::next;
  2101 //    NodeIt& next(NodeIt& i) const { graph->next(i.n); return i; }
  2107 // //    NodeIt& next(NodeIt& i) const { graph->next(i.n); return i; }
  2102     OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; }
  2108 //     OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; }
  2103     InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; }
  2109 //     InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; }
  2104     EdgeIt& next(EdgeIt& i) const { this->graph->next(i.e); return i; }    
  2110 //     EdgeIt& next(EdgeIt& i) const { this->graph->next(i.e); return i; }    
  2105     
  2111     
  2106     Node aNode(const OutEdgeIt& e) const { 
  2112 //     Node aNode(const OutEdgeIt& e) const { 
  2107       return Node(this->graph->aNode(e.e)); }
  2113 //       return Node(this->graph->aNode(e.e)); }
  2108     Node aNode(const InEdgeIt& e) const { 
  2114 //     Node aNode(const InEdgeIt& e) const { 
  2109       return Node(this->graph->aNode(e.e)); }
  2115 //       return Node(this->graph->aNode(e.e)); }
  2110     Node bNode(const OutEdgeIt& e) const { 
  2116 //     Node bNode(const OutEdgeIt& e) const { 
  2111       return Node(this->graph->bNode(e.e)); }
  2117 //       return Node(this->graph->bNode(e.e)); }
  2112     Node bNode(const InEdgeIt& e) const { 
  2118 //     Node bNode(const InEdgeIt& e) const { 
  2113       return Node(this->graph->bNode(e.e)); }
  2119 //       return Node(this->graph->bNode(e.e)); }
  2114 
  2120 
  2115     void erase(const OutEdgeIt& e) const {
  2121     void erase(const Edge& e) const {
  2116       OutEdgeIt f=e;
  2122       Node n=tail(e);
  2117       this->next(f);
  2123       typename Graph::OutEdgeIt f(*graph, n);
  2118       first_out_edges->set(this->tail(e), f.e);
  2124       ++f;
       
  2125       first_out_edges->set(n, f);
  2119     }
  2126     }
  2120   };
  2127   };
  2121 
  2128 
  2122   ///@}
  2129   ///@}
  2123 
  2130