69 friend class ClassNodeIt; |
69 friend class ClassNodeIt; |
70 class OutEdgeIt; |
70 class OutEdgeIt; |
71 friend class OutEdgeIt; |
71 friend class OutEdgeIt; |
72 class InEdgeIt; |
72 class InEdgeIt; |
73 friend class InEdgeIt; |
73 friend class InEdgeIt; |
74 class ClassNodeIt { |
74 class ClassNodeIt : public Node { |
75 friend class BipartiteGraphWrapper<Graph>; |
75 friend class BipartiteGraphWrapper<Graph>; |
76 protected: |
76 protected: |
77 Node n; |
77 const BipartiteGraphWrapper<Graph>* gw; |
78 public: |
78 public: |
79 ClassNodeIt() { } |
79 ClassNodeIt() { } |
80 ClassNodeIt(const Invalid& i) : n(i) { } |
80 ClassNodeIt(Invalid i) : Node(i) { } |
81 ClassNodeIt(const BipartiteGraphWrapper<Graph>& _G, bool _class) { |
81 ClassNodeIt(const BipartiteGraphWrapper<Graph>& _gw, bool _class) : |
82 _G.s_false_t_true_map->first(n, _class); |
82 Node(), gw(&_gw) { |
|
83 _gw.s_false_t_true_map->first(*this, _class); |
83 } |
84 } |
84 //FIXME needed in new concept, important here |
85 //FIXME needed in new concept, important here |
85 ClassNodeIt(const Node& _n) : n(_n) { } |
86 ClassNodeIt(const BipartiteGraphWrapper<Graph>& _gw, const Node& n) : |
86 operator Node() const { return n; } |
87 Node(n), gw(&_gw) { } |
|
88 ClassNodeIt& operator++() { |
|
89 gw->s_false_t_true_map->next(*this); |
|
90 return *this; |
|
91 } |
87 }; |
92 }; |
88 // class SNodeIt { |
93 // class SNodeIt { |
89 // Node n; |
94 // Node n; |
90 // public: |
95 // public: |
91 // SNodeIt() { } |
96 // SNodeIt() { } |
103 // TNodeIt(const BipartiteGraphWrapper<Graph>& _G) { |
108 // TNodeIt(const BipartiteGraphWrapper<Graph>& _G) { |
104 // _G.s_false_t_true_map->first(n, true); |
109 // _G.s_false_t_true_map->first(n, true); |
105 // } |
110 // } |
106 // operator Node() const { return n; } |
111 // operator Node() const { return n; } |
107 // }; |
112 // }; |
108 class OutEdgeIt { |
113 // class OutEdgeIt { |
109 friend class BipartiteGraphWrapper<Graph>; |
114 // friend class BipartiteGraphWrapper<Graph>; |
110 protected: |
115 // protected: |
111 typename Graph::OutEdgeIt e; |
116 // typename Graph::OutEdgeIt e; |
112 public: |
117 // public: |
113 OutEdgeIt() { } |
118 // OutEdgeIt() { } |
114 OutEdgeIt(const Invalid& i) : e(i) { } |
119 // OutEdgeIt(const Invalid& i) : e(i) { } |
115 OutEdgeIt(const BipartiteGraphWrapper<Graph>& _G, const Node& _n) { |
120 // OutEdgeIt(const BipartiteGraphWrapper<Graph>& _G, const Node& _n) { |
116 if (!(*(_G.s_false_t_true_map))[_n]) |
121 // if (!(*(_G.s_false_t_true_map))[_n]) |
117 e=typename Graph::OutEdgeIt(*(_G.graph), typename Graph::Node(_n)); |
122 // e=typename Graph::OutEdgeIt(*(_G.graph), typename Graph::Node(_n)); |
118 else |
123 // else |
119 e=INVALID; |
124 // e=INVALID; |
120 } |
125 // } |
121 operator Edge() const { return Edge(typename Graph::Edge(e)); } |
126 // operator Edge() const { return Edge(typename Graph::Edge(e)); } |
122 }; |
127 // }; |
123 class InEdgeIt { |
128 // class InEdgeIt { |
124 friend class BipartiteGraphWrapper<Graph>; |
129 // friend class BipartiteGraphWrapper<Graph>; |
125 protected: |
130 // protected: |
126 typename Graph::InEdgeIt e; |
131 // typename Graph::InEdgeIt e; |
127 public: |
132 // public: |
128 InEdgeIt() { } |
133 // InEdgeIt() { } |
129 InEdgeIt(const Invalid& i) : e(i) { } |
134 // InEdgeIt(const Invalid& i) : e(i) { } |
130 InEdgeIt(const BipartiteGraphWrapper<Graph>& _G, const Node& _n) { |
135 // InEdgeIt(const BipartiteGraphWrapper<Graph>& _G, const Node& _n) { |
131 if ((*(_G.s_false_t_true_map))[_n]) |
136 // if ((*(_G.s_false_t_true_map))[_n]) |
132 e=typename Graph::InEdgeIt(*(_G.graph), typename Graph::Node(_n)); |
137 // e=typename Graph::InEdgeIt(*(_G.graph), typename Graph::Node(_n)); |
133 else |
138 // else |
134 e=INVALID; |
139 // e=INVALID; |
135 } |
140 // } |
136 operator Edge() const { return Edge(typename Graph::Edge(e)); } |
141 // operator Edge() const { return Edge(typename Graph::Edge(e)); } |
137 }; |
142 // }; |
138 |
143 |
139 using GraphWrapper<Graph>::first; |
144 using GraphWrapper<Graph>::first; |
140 ClassNodeIt& first(ClassNodeIt& n, bool _class) const { |
145 ClassNodeIt& first(ClassNodeIt& n, bool _class) const { |
141 n=ClassNodeIt(*this, _class) ; return n; } |
146 n=ClassNodeIt(*this, _class); return n; |
|
147 } |
142 // SNodeIt& first(SNodeIt& n) const { n=SNodeIt(*this); return n; } |
148 // SNodeIt& first(SNodeIt& n) const { n=SNodeIt(*this); return n; } |
143 // TNodeIt& first(TNodeIt& n) const { n=TNodeIt(*this); return n; } |
149 // TNodeIt& first(TNodeIt& n) const { n=TNodeIt(*this); return n; } |
144 OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { |
150 // OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { |
145 i=OutEdgeIt(*this, p); return i; |
151 // i=OutEdgeIt(*this, p); return i; |
146 } |
152 // } |
147 InEdgeIt& first(InEdgeIt& i, const Node& p) const { |
153 // InEdgeIt& first(InEdgeIt& i, const Node& p) const { |
148 i=InEdgeIt(*this, p); return i; |
154 // i=InEdgeIt(*this, p); return i; |
149 } |
155 // } |
150 |
156 |
151 using GraphWrapper<Graph>::next; |
157 // using GraphWrapper<Graph>::next; |
152 ClassNodeIt& next(ClassNodeIt& n) const { |
158 // ClassNodeIt& next(ClassNodeIt& n) const { |
153 this->s_false_t_true_map->next(n.n); return n; |
159 // this->s_false_t_true_map->next(n.n); return n; |
154 } |
160 // } |
155 // SNodeIt& next(SNodeIt& n) const { |
161 // SNodeIt& next(SNodeIt& n) const { |
156 // this->s_false_t_true_map->next(n); return n; |
162 // this->s_false_t_true_map->next(n); return n; |
157 // } |
163 // } |
158 // TNodeIt& next(TNodeIt& n) const { |
164 // TNodeIt& next(TNodeIt& n) const { |
159 // this->s_false_t_true_map->next(n); return n; |
165 // this->s_false_t_true_map->next(n); return n; |
160 // } |
166 // } |
161 OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; } |
167 // OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; } |
162 InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; } |
168 // InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; } |
163 |
169 |
164 Node tail(const Edge& e) { |
170 // Node tail(const Edge& e) { |
165 if (!(*(this->s_false_t_true_map))[this->graph->tail(e)]) |
171 // if (!(*(this->s_false_t_true_map))[this->graph->tail(e)]) |
166 return Node(this->graph->tail(e)); |
172 // return Node(this->graph->tail(e)); |
167 else |
173 // else |
168 return Node(this->graph->head(e)); |
174 // return Node(this->graph->head(e)); |
169 } |
175 // } |
170 Node head(const Edge& e) { |
176 // Node head(const Edge& e) { |
171 if (!(*(this->s_false_t_true_map))[this->graph->tail(e)]) |
177 // if (!(*(this->s_false_t_true_map))[this->graph->tail(e)]) |
172 return Node(this->graph->head(e)); |
178 // return Node(this->graph->head(e)); |
173 else |
179 // else |
174 return Node(this->graph->tail(e)); |
180 // return Node(this->graph->tail(e)); |
175 } |
181 // } |
176 |
182 |
177 Node aNode(const OutEdgeIt& e) const { |
183 // Node aNode(const OutEdgeIt& e) const { |
178 return Node(this->graph->aNode(e.e)); |
184 // return Node(this->graph->aNode(e.e)); |
179 } |
185 // } |
180 Node aNode(const InEdgeIt& e) const { |
186 // Node aNode(const InEdgeIt& e) const { |
181 return Node(this->graph->aNode(e.e)); |
187 // return Node(this->graph->aNode(e.e)); |
182 } |
188 // } |
183 Node bNode(const OutEdgeIt& e) const { |
189 // Node bNode(const OutEdgeIt& e) const { |
184 return Node(this->graph->bNode(e.e)); |
190 // return Node(this->graph->bNode(e.e)); |
185 } |
191 // } |
186 Node bNode(const InEdgeIt& e) const { |
192 // Node bNode(const InEdgeIt& e) const { |
187 return Node(this->graph->bNode(e.e)); |
193 // return Node(this->graph->bNode(e.e)); |
188 } |
194 // } |
189 |
195 |
190 /// Returns true iff \c n is in S. |
196 /// Returns true iff \c n is in S. |
191 bool inSClass(const Node& n) const { |
197 bool inSClass(const Node& n) const { |
192 return !(*(this->s_false_t_true_map))[n]; |
198 return !(*(this->s_false_t_true_map))[n]; |
193 } |
199 } |