lemon/bits/iterable_graph_extender.h
changeset 1923 e1b0ef823e9e
parent 1909 2d806130e700
child 1933 a876a3d6a4c7
equal deleted inserted replaced
6:66a1098c5c83 7:f9338d68285b
   268 
   268 
   269   };
   269   };
   270 
   270 
   271 
   271 
   272   template <typename _Base>
   272   template <typename _Base>
   273   class IterableUBipartiteGraphExtender : public _Base {
   273   class IterableBpUGraphExtender : public _Base {
   274   public:
   274   public:
   275     typedef _Base Parent;
   275     typedef _Base Parent;
   276     typedef IterableUBipartiteGraphExtender Graph;
   276     typedef IterableBpUGraphExtender Graph;
   277    
   277    
   278     typedef typename Parent::Node Node;
   278     typedef typename Parent::Node Node;
   279     typedef typename Parent::UpperNode UpperNode;
   279     typedef typename Parent::ANode ANode;
   280     typedef typename Parent::LowerNode LowerNode;
   280     typedef typename Parent::BNode BNode;
   281     typedef typename Parent::Edge Edge;
   281     typedef typename Parent::Edge Edge;
   282     typedef typename Parent::UEdge UEdge;
   282     typedef typename Parent::UEdge UEdge;
   283   
   283   
   284     class NodeIt : public Node { 
   284     class NodeIt : public Node { 
   285       const Graph* graph;
   285       const Graph* graph;
   301 	return *this; 
   301 	return *this; 
   302       }
   302       }
   303 
   303 
   304     };
   304     };
   305 
   305 
   306     class UpperNodeIt : public Node { 
   306     class ANodeIt : public Node { 
   307       friend class IterableUBipartiteGraphExtender;
   307       friend class IterableBpUGraphExtender;
   308       const Graph* graph;
   308       const Graph* graph;
   309     public:
   309     public:
   310     
   310     
   311       UpperNodeIt() { }
   311       ANodeIt() { }
   312     
   312     
   313       UpperNodeIt(Invalid i) : Node(INVALID) { }
   313       ANodeIt(Invalid i) : Node(INVALID) { }
   314     
   314     
   315       explicit UpperNodeIt(const Graph& _graph) : graph(&_graph) {
   315       explicit ANodeIt(const Graph& _graph) : graph(&_graph) {
   316 	graph->firstUpper(static_cast<Node&>(*this));
   316 	graph->firstANode(static_cast<Node&>(*this));
   317       }
   317       }
   318 
   318 
   319       UpperNodeIt(const Graph& _graph, const Node& node) 
   319       ANodeIt(const Graph& _graph, const Node& node) 
   320 	: Node(node), graph(&_graph) {}
   320 	: Node(node), graph(&_graph) {}
   321     
   321     
   322       UpperNodeIt& operator++() { 
   322       ANodeIt& operator++() { 
   323 	graph->nextUpper(*this);
   323 	graph->nextANode(*this);
   324 	return *this; 
   324 	return *this; 
   325       }
   325       }
   326     };
   326     };
   327 
   327 
   328     class LowerNodeIt : public Node { 
   328     class BNodeIt : public Node { 
   329       friend class IterableUBipartiteGraphExtender;
   329       friend class IterableBpUGraphExtender;
   330       const Graph* graph;
   330       const Graph* graph;
   331     public:
   331     public:
   332     
   332     
   333       LowerNodeIt() { }
   333       BNodeIt() { }
   334     
   334     
   335       LowerNodeIt(Invalid i) : Node(INVALID) { }
   335       BNodeIt(Invalid i) : Node(INVALID) { }
   336     
   336     
   337       explicit LowerNodeIt(const Graph& _graph) : graph(&_graph) {
   337       explicit BNodeIt(const Graph& _graph) : graph(&_graph) {
   338 	graph->firstLower(static_cast<Node&>(*this));
   338 	graph->firstBNode(static_cast<Node&>(*this));
   339       }
   339       }
   340 
   340 
   341       LowerNodeIt(const Graph& _graph, const Node& node) 
   341       BNodeIt(const Graph& _graph, const Node& node) 
   342 	: Node(node), graph(&_graph) {}
   342 	: Node(node), graph(&_graph) {}
   343     
   343     
   344       LowerNodeIt& operator++() { 
   344       BNodeIt& operator++() { 
   345 	graph->nextLower(*this);
   345 	graph->nextBNode(*this);
   346 	return *this; 
   346 	return *this; 
   347       }
   347       }
   348     };
   348     };
   349 
   349 
   350     class EdgeIt : public Edge { 
   350     class EdgeIt : public Edge { 
   351       friend class IterableUBipartiteGraphExtender;
   351       friend class IterableBpUGraphExtender;
   352       const Graph* graph;
   352       const Graph* graph;
   353     public:
   353     public:
   354     
   354     
   355       EdgeIt() { }
   355       EdgeIt() { }
   356     
   356     
   369       }
   369       }
   370 
   370 
   371     };
   371     };
   372 
   372 
   373     class UEdgeIt : public UEdge { 
   373     class UEdgeIt : public UEdge { 
   374       friend class IterableUBipartiteGraphExtender;
   374       friend class IterableBpUGraphExtender;
   375       const Graph* graph;
   375       const Graph* graph;
   376     public:
   376     public:
   377     
   377     
   378       UEdgeIt() { }
   378       UEdgeIt() { }
   379     
   379     
   391 	return *this; 
   391 	return *this; 
   392       }
   392       }
   393     };
   393     };
   394 
   394 
   395     class OutEdgeIt : public Edge { 
   395     class OutEdgeIt : public Edge { 
   396       friend class IterableUBipartiteGraphExtender;
   396       friend class IterableBpUGraphExtender;
   397       const Graph* graph;
   397       const Graph* graph;
   398     public:
   398     public:
   399     
   399     
   400       OutEdgeIt() { }
   400       OutEdgeIt() { }
   401     
   401     
   416 
   416 
   417     };
   417     };
   418 
   418 
   419 
   419 
   420     class InEdgeIt : public Edge { 
   420     class InEdgeIt : public Edge { 
   421       friend class IterableUBipartiteGraphExtender;
   421       friend class IterableBpUGraphExtender;
   422       const Graph* graph;
   422       const Graph* graph;
   423     public:
   423     public:
   424     
   424     
   425       InEdgeIt() { }
   425       InEdgeIt() { }
   426     
   426     
   468     Node runningNode(const InEdgeIt &e) const {
   468     Node runningNode(const InEdgeIt &e) const {
   469       return Parent::source((Edge&)e);
   469       return Parent::source((Edge&)e);
   470     }
   470     }
   471   
   471   
   472     class IncEdgeIt : public Parent::UEdge { 
   472     class IncEdgeIt : public Parent::UEdge { 
   473       friend class IterableUBipartiteGraphExtender;
   473       friend class IterableBpUGraphExtender;
   474       const Graph* graph;
   474       const Graph* graph;
   475       bool direction;
   475       bool direction;
   476     public:
   476     public:
   477     
   477     
   478       IncEdgeIt() { }
   478       IncEdgeIt() { }