lemon/bits/graph_adaptor_extender.h
changeset 2031 080d51024ac5
parent 1996 5dc13b93f8b4
child 2041 28df5272df99
equal deleted inserted replaced
1:59b65b9059aa 2:275b88f95436
    31 namespace lemon {
    31 namespace lemon {
    32 
    32 
    33   /// \ingroup graphbits
    33   /// \ingroup graphbits
    34   ///
    34   ///
    35   /// \brief Extender for the GraphAdaptors
    35   /// \brief Extender for the GraphAdaptors
    36   template <typename Base>
    36   template <typename _Graph>
    37   class GraphAdaptorExtender : public Base {
    37   class GraphAdaptorExtender : public _Graph {
    38   public:
    38   public:
    39 
    39 
    40     typedef Base Parent;
    40     typedef _Graph Parent;
    41     typedef GraphAdaptorExtender Graph;
    41     typedef _Graph Graph;
       
    42     typedef GraphAdaptorExtender Adaptor;
    42 
    43 
    43     // Base extensions
    44     // Base extensions
    44 
    45 
    45     typedef typename Parent::Node Node;
    46     typedef typename Parent::Node Node;
    46     typedef typename Parent::Edge Edge;
    47     typedef typename Parent::Edge Edge;
    69       else
    70       else
    70 	return INVALID;
    71 	return INVALID;
    71     }
    72     }
    72 
    73 
    73     class NodeIt : public Node { 
    74     class NodeIt : public Node { 
    74       const Graph* graph;
    75       const Adaptor* graph;
    75     public:
    76     public:
    76 
    77 
    77       NodeIt() {}
    78       NodeIt() {}
    78 
    79 
    79       NodeIt(Invalid i) : Node(i) { }
    80       NodeIt(Invalid i) : Node(i) { }
    80 
    81 
    81       explicit NodeIt(const Graph& _graph) : graph(&_graph) {
    82       explicit NodeIt(const Adaptor& _graph) : graph(&_graph) {
    82 	_graph.first(*static_cast<Node*>(this));
    83 	_graph.first(static_cast<Node&>(*this));
    83       }
    84       }
    84 
    85 
    85       NodeIt(const Graph& _graph, const Node& node) 
    86       NodeIt(const Adaptor& _graph, const Node& node) 
    86 	: Node(node), graph(&_graph) {}
    87 	: Node(node), graph(&_graph) {}
    87 
    88 
    88       NodeIt& operator++() { 
    89       NodeIt& operator++() { 
    89 	graph->next(*this);
    90 	graph->next(*this);
    90 	return *this; 
    91 	return *this; 
    92 
    93 
    93     };
    94     };
    94 
    95 
    95 
    96 
    96     class EdgeIt : public Edge { 
    97     class EdgeIt : public Edge { 
    97       const Graph* graph;
    98       const Adaptor* graph;
    98     public:
    99     public:
    99 
   100 
   100       EdgeIt() { }
   101       EdgeIt() { }
   101 
   102 
   102       EdgeIt(Invalid i) : Edge(i) { }
   103       EdgeIt(Invalid i) : Edge(i) { }
   103 
   104 
   104       explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
   105       explicit EdgeIt(const Adaptor& _graph) : graph(&_graph) {
   105 	_graph.first(*static_cast<Edge*>(this));
   106 	_graph.first(static_cast<Edge&>(*this));
   106       }
   107       }
   107 
   108 
   108       EdgeIt(const Graph& _graph, const Edge& e) : 
   109       EdgeIt(const Adaptor& _graph, const Edge& e) : 
   109 	Edge(e), graph(&_graph) { }
   110 	Edge(e), graph(&_graph) { }
   110 
   111 
   111       EdgeIt& operator++() { 
   112       EdgeIt& operator++() { 
   112 	graph->next(*this);
   113 	graph->next(*this);
   113 	return *this; 
   114 	return *this; 
   115 
   116 
   116     };
   117     };
   117 
   118 
   118 
   119 
   119     class OutEdgeIt : public Edge { 
   120     class OutEdgeIt : public Edge { 
   120       const Graph* graph;
   121       const Adaptor* graph;
   121     public:
   122     public:
   122 
   123 
   123       OutEdgeIt() { }
   124       OutEdgeIt() { }
   124 
   125 
   125       OutEdgeIt(Invalid i) : Edge(i) { }
   126       OutEdgeIt(Invalid i) : Edge(i) { }
   126 
   127 
   127       OutEdgeIt(const Graph& _graph, const Node& node) 
   128       OutEdgeIt(const Adaptor& _graph, const Node& node) 
   128 	: graph(&_graph) {
   129 	: graph(&_graph) {
   129 	_graph.firstOut(*this, node);
   130 	_graph.firstOut(*this, node);
   130       }
   131       }
   131 
   132 
   132       OutEdgeIt(const Graph& _graph, const Edge& edge) 
   133       OutEdgeIt(const Adaptor& _graph, const Edge& edge) 
   133 	: Edge(edge), graph(&_graph) {}
   134 	: Edge(edge), graph(&_graph) {}
   134 
   135 
   135       OutEdgeIt& operator++() { 
   136       OutEdgeIt& operator++() { 
   136 	graph->nextOut(*this);
   137 	graph->nextOut(*this);
   137 	return *this; 
   138 	return *this; 
   139 
   140 
   140     };
   141     };
   141 
   142 
   142 
   143 
   143     class InEdgeIt : public Edge { 
   144     class InEdgeIt : public Edge { 
   144       const Graph* graph;
   145       const Adaptor* graph;
   145     public:
   146     public:
   146 
   147 
   147       InEdgeIt() { }
   148       InEdgeIt() { }
   148 
   149 
   149       InEdgeIt(Invalid i) : Edge(i) { }
   150       InEdgeIt(Invalid i) : Edge(i) { }
   150 
   151 
   151       InEdgeIt(const Graph& _graph, const Node& node) 
   152       InEdgeIt(const Adaptor& _graph, const Node& node) 
   152 	: graph(&_graph) {
   153 	: graph(&_graph) {
   153 	_graph.firstIn(*this, node);
   154 	_graph.firstIn(*this, node);
   154       }
   155       }
   155 
   156 
   156       InEdgeIt(const Graph& _graph, const Edge& edge) : 
   157       InEdgeIt(const Adaptor& _graph, const Edge& edge) : 
   157 	Edge(edge), graph(&_graph) {}
   158 	Edge(edge), graph(&_graph) {}
   158 
   159 
   159       InEdgeIt& operator++() { 
   160       InEdgeIt& operator++() { 
   160 	graph->nextIn(*this);
   161 	graph->nextIn(*this);
   161 	return *this; 
   162 	return *this; 
   195 
   196 
   196 
   197 
   197   /// \ingroup graphbits
   198   /// \ingroup graphbits
   198   ///
   199   ///
   199   /// \brief Extender for the UGraphAdaptors
   200   /// \brief Extender for the UGraphAdaptors
   200   template <typename Base> 
   201   template <typename _UGraph> 
   201   class UGraphAdaptorExtender : public Base {
   202   class UGraphAdaptorExtender : public _UGraph {
   202   public:
   203   public:
   203     
   204     
   204     typedef Base Parent;
   205     typedef _UGraph Parent;
   205     typedef UGraphAdaptorExtender Graph;
   206     typedef _UGraph UGraph;
       
   207     typedef UGraphAdaptorExtender Adaptor;
   206 
   208 
   207     typedef typename Parent::Node Node;
   209     typedef typename Parent::Node Node;
   208     typedef typename Parent::Edge Edge;
   210     typedef typename Parent::Edge Edge;
   209     typedef typename Parent::UEdge UEdge;
   211     typedef typename Parent::UEdge UEdge;
   210 
   212 
   252       return Parent::direct(ue, Parent::source(ue) == s);
   254       return Parent::direct(ue, Parent::source(ue) == s);
   253     }
   255     }
   254 
   256 
   255 
   257 
   256     class NodeIt : public Node { 
   258     class NodeIt : public Node { 
   257       const Graph* graph;
   259       const Adaptor* graph;
   258     public:
   260     public:
   259 
   261 
   260       NodeIt() {}
   262       NodeIt() {}
   261 
   263 
   262       NodeIt(Invalid i) : Node(i) { }
   264       NodeIt(Invalid i) : Node(i) { }
   263 
   265 
   264       explicit NodeIt(const Graph& _graph) : graph(&_graph) {
   266       explicit NodeIt(const Adaptor& _graph) : graph(&_graph) {
   265 	_graph.first(*static_cast<Node*>(this));
   267 	_graph.first(static_cast<Node&>(*this));
   266       }
   268       }
   267 
   269 
   268       NodeIt(const Graph& _graph, const Node& node) 
   270       NodeIt(const Adaptor& _graph, const Node& node) 
   269 	: Node(node), graph(&_graph) {}
   271 	: Node(node), graph(&_graph) {}
   270 
   272 
   271       NodeIt& operator++() { 
   273       NodeIt& operator++() { 
   272 	graph->next(*this);
   274 	graph->next(*this);
   273 	return *this; 
   275 	return *this; 
   275 
   277 
   276     };
   278     };
   277 
   279 
   278 
   280 
   279     class EdgeIt : public Edge { 
   281     class EdgeIt : public Edge { 
   280       const Graph* graph;
   282       const Adaptor* graph;
   281     public:
   283     public:
   282 
   284 
   283       EdgeIt() { }
   285       EdgeIt() { }
   284 
   286 
   285       EdgeIt(Invalid i) : Edge(i) { }
   287       EdgeIt(Invalid i) : Edge(i) { }
   286 
   288 
   287       explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
   289       explicit EdgeIt(const Adaptor& _graph) : graph(&_graph) {
   288 	_graph.first(*static_cast<Edge*>(this));
   290 	_graph.first(static_cast<Edge&>(*this));
   289       }
   291       }
   290 
   292 
   291       EdgeIt(const Graph& _graph, const Edge& e) : 
   293       EdgeIt(const Adaptor& _graph, const Edge& e) : 
   292 	Edge(e), graph(&_graph) { }
   294 	Edge(e), graph(&_graph) { }
   293 
   295 
   294       EdgeIt& operator++() { 
   296       EdgeIt& operator++() { 
   295 	graph->next(*this);
   297 	graph->next(*this);
   296 	return *this; 
   298 	return *this; 
   298 
   300 
   299     };
   301     };
   300 
   302 
   301 
   303 
   302     class OutEdgeIt : public Edge { 
   304     class OutEdgeIt : public Edge { 
   303       const Graph* graph;
   305       const Adaptor* graph;
   304     public:
   306     public:
   305 
   307 
   306       OutEdgeIt() { }
   308       OutEdgeIt() { }
   307 
   309 
   308       OutEdgeIt(Invalid i) : Edge(i) { }
   310       OutEdgeIt(Invalid i) : Edge(i) { }
   309 
   311 
   310       OutEdgeIt(const Graph& _graph, const Node& node) 
   312       OutEdgeIt(const Adaptor& _graph, const Node& node) 
   311 	: graph(&_graph) {
   313 	: graph(&_graph) {
   312 	_graph.firstOut(*this, node);
   314 	_graph.firstOut(*this, node);
   313       }
   315       }
   314 
   316 
   315       OutEdgeIt(const Graph& _graph, const Edge& edge) 
   317       OutEdgeIt(const Adaptor& _graph, const Edge& edge) 
   316 	: Edge(edge), graph(&_graph) {}
   318 	: Edge(edge), graph(&_graph) {}
   317 
   319 
   318       OutEdgeIt& operator++() { 
   320       OutEdgeIt& operator++() { 
   319 	graph->nextOut(*this);
   321 	graph->nextOut(*this);
   320 	return *this; 
   322 	return *this; 
   322 
   324 
   323     };
   325     };
   324 
   326 
   325 
   327 
   326     class InEdgeIt : public Edge { 
   328     class InEdgeIt : public Edge { 
   327       const Graph* graph;
   329       const Adaptor* graph;
   328     public:
   330     public:
   329 
   331 
   330       InEdgeIt() { }
   332       InEdgeIt() { }
   331 
   333 
   332       InEdgeIt(Invalid i) : Edge(i) { }
   334       InEdgeIt(Invalid i) : Edge(i) { }
   333 
   335 
   334       InEdgeIt(const Graph& _graph, const Node& node) 
   336       InEdgeIt(const Adaptor& _graph, const Node& node) 
   335 	: graph(&_graph) {
   337 	: graph(&_graph) {
   336 	_graph.firstIn(*this, node);
   338 	_graph.firstIn(*this, node);
   337       }
   339       }
   338 
   340 
   339       InEdgeIt(const Graph& _graph, const Edge& edge) : 
   341       InEdgeIt(const Adaptor& _graph, const Edge& edge) : 
   340 	Edge(edge), graph(&_graph) {}
   342 	Edge(edge), graph(&_graph) {}
   341 
   343 
   342       InEdgeIt& operator++() { 
   344       InEdgeIt& operator++() { 
   343 	graph->nextIn(*this);
   345 	graph->nextIn(*this);
   344 	return *this; 
   346 	return *this; 
   345       }
   347       }
   346 
   348 
   347     };
   349     };
   348 
   350 
   349     class UEdgeIt : public Parent::UEdge { 
   351     class UEdgeIt : public Parent::UEdge { 
   350       const Graph* graph;
   352       const Adaptor* graph;
   351     public:
   353     public:
   352 
   354 
   353       UEdgeIt() { }
   355       UEdgeIt() { }
   354 
   356 
   355       UEdgeIt(Invalid i) : UEdge(i) { }
   357       UEdgeIt(Invalid i) : UEdge(i) { }
   356 
   358 
   357       explicit UEdgeIt(const Graph& _graph) : graph(&_graph) {
   359       explicit UEdgeIt(const Adaptor& _graph) : graph(&_graph) {
   358 	_graph.first(*static_cast<UEdge*>(this));
   360 	_graph.first(static_cast<UEdge&>(*this));
   359       }
   361       }
   360 
   362 
   361       UEdgeIt(const Graph& _graph, const UEdge& e) : 
   363       UEdgeIt(const Adaptor& _graph, const UEdge& e) : 
   362 	UEdge(e), graph(&_graph) { }
   364 	UEdge(e), graph(&_graph) { }
   363 
   365 
   364       UEdgeIt& operator++() { 
   366       UEdgeIt& operator++() { 
   365 	graph->next(*this);
   367 	graph->next(*this);
   366 	return *this; 
   368 	return *this; 
   368 
   370 
   369     };
   371     };
   370 
   372 
   371     class IncEdgeIt : public Parent::UEdge { 
   373     class IncEdgeIt : public Parent::UEdge { 
   372       friend class UGraphAdaptorExtender;
   374       friend class UGraphAdaptorExtender;
   373       const Graph* graph;
   375       const Adaptor* graph;
   374       bool direction;
   376       bool direction;
   375     public:
   377     public:
   376 
   378 
   377       IncEdgeIt() { }
   379       IncEdgeIt() { }
   378 
   380 
   379       IncEdgeIt(Invalid i) : UEdge(i), direction(false) { }
   381       IncEdgeIt(Invalid i) : UEdge(i), direction(false) { }
   380 
   382 
   381       IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
   383       IncEdgeIt(const Adaptor& _graph, const Node &n) : graph(&_graph) {
   382 	_graph.firstInc(static_cast<UEdge&>(*this), direction, n);
   384 	_graph.firstInc(static_cast<UEdge&>(*this), direction, n);
   383       }
   385       }
   384 
   386 
   385       IncEdgeIt(const Graph& _graph, const UEdge &ue, const Node &n)
   387       IncEdgeIt(const Adaptor& _graph, const UEdge &ue, const Node &n)
   386 	: graph(&_graph), UEdge(ue) {
   388 	: graph(&_graph), UEdge(ue) {
   387 	direction = (_graph.source(ue) == n);
   389 	direction = (_graph.source(ue) == n);
   388       }
   390       }
   389 
   391 
   390       IncEdgeIt& operator++() {
   392       IncEdgeIt& operator++() {
   434       return e.direction ? target(e) : source(e);
   436       return e.direction ? target(e) : source(e);
   435     }
   437     }
   436 
   438 
   437   };
   439   };
   438 
   440 
       
   441   /// \ingroup graphbits
       
   442   ///
       
   443   /// \brief Extender for the BpUGraphAdaptors
       
   444   template <typename Base>
       
   445   class BpUGraphAdaptorExtender : public Base {
       
   446   public:
       
   447     typedef Base Parent;
       
   448     typedef BpUGraphAdaptorExtender Graph;
       
   449 
       
   450     typedef typename Parent::Node Node;
       
   451     typedef typename Parent::BNode BNode;
       
   452     typedef typename Parent::ANode ANode;
       
   453     typedef typename Parent::Edge Edge;
       
   454     typedef typename Parent::UEdge UEdge;
       
   455 
       
   456     Node oppositeNode(const UEdge& edge, const Node& node) const {
       
   457       return source(edge) == node ? 
       
   458 	target(edge) : source(edge);
       
   459     }
       
   460 
       
   461 
       
   462     int maxId(Node) const {
       
   463       return Parent::maxNodeId();
       
   464     }
       
   465     int maxId(BNode) const {
       
   466       return Parent::maxBNodeId();
       
   467     }
       
   468     int maxId(ANode) const {
       
   469       return Parent::maxANodeId();
       
   470     }
       
   471     int maxId(Edge) const {
       
   472       return Parent::maxEdgeId();
       
   473     }
       
   474     int maxId(UEdge) const {
       
   475       return Parent::maxUEdgeId();
       
   476     }
       
   477 
       
   478 
       
   479     Node fromId(int id, Node) const {
       
   480       return Parent::nodeFromId(id);
       
   481     }
       
   482     ANode fromId(int id, ANode) const {
       
   483       return Parent::fromANodeId(id);
       
   484     }
       
   485     BNode fromId(int id, BNode) const {
       
   486       return Parent::fromBNodeId(id);
       
   487     }
       
   488     Edge fromId(int id, Edge) const {
       
   489       return Parent::edgeFromId(id);
       
   490     }
       
   491     UEdge fromId(int id, UEdge) const {
       
   492       return Parent::uEdgeFromId(id);
       
   493     }  
       
   494   
       
   495     class NodeIt : public Node { 
       
   496       const Graph* graph;
       
   497     public:
       
   498     
       
   499       NodeIt() { }
       
   500     
       
   501       NodeIt(Invalid i) : Node(INVALID) { }
       
   502     
       
   503       explicit NodeIt(const Graph& _graph) : graph(&_graph) {
       
   504 	graph->first(static_cast<Node&>(*this));
       
   505       }
       
   506 
       
   507       NodeIt(const Graph& _graph, const Node& node) 
       
   508 	: Node(node), graph(&_graph) { }
       
   509     
       
   510       NodeIt& operator++() { 
       
   511 	graph->next(*this);
       
   512 	return *this; 
       
   513       }
       
   514 
       
   515     };
       
   516 
       
   517     class ANodeIt : public Node { 
       
   518       friend class BpUGraphAdaptorExtender;
       
   519       const Graph* graph;
       
   520     public:
       
   521     
       
   522       ANodeIt() { }
       
   523     
       
   524       ANodeIt(Invalid i) : Node(INVALID) { }
       
   525     
       
   526       explicit ANodeIt(const Graph& _graph) : graph(&_graph) {
       
   527 	graph->firstANode(static_cast<Node&>(*this));
       
   528       }
       
   529 
       
   530       ANodeIt(const Graph& _graph, const Node& node) 
       
   531 	: Node(node), graph(&_graph) {}
       
   532     
       
   533       ANodeIt& operator++() { 
       
   534 	graph->nextANode(*this);
       
   535 	return *this; 
       
   536       }
       
   537     };
       
   538 
       
   539     class BNodeIt : public Node { 
       
   540       friend class BpUGraphAdaptorExtender;
       
   541       const Graph* graph;
       
   542     public:
       
   543     
       
   544       BNodeIt() { }
       
   545     
       
   546       BNodeIt(Invalid i) : Node(INVALID) { }
       
   547     
       
   548       explicit BNodeIt(const Graph& _graph) : graph(&_graph) {
       
   549 	graph->firstBNode(static_cast<Node&>(*this));
       
   550       }
       
   551 
       
   552       BNodeIt(const Graph& _graph, const Node& node) 
       
   553 	: Node(node), graph(&_graph) {}
       
   554     
       
   555       BNodeIt& operator++() { 
       
   556 	graph->nextBNode(*this);
       
   557 	return *this; 
       
   558       }
       
   559     };
       
   560 
       
   561     class EdgeIt : public Edge { 
       
   562       friend class BpUGraphAdaptorExtender;
       
   563       const Graph* graph;
       
   564     public:
       
   565     
       
   566       EdgeIt() { }
       
   567     
       
   568       EdgeIt(Invalid i) : Edge(INVALID) { }
       
   569     
       
   570       explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
       
   571 	graph->first(static_cast<Edge&>(*this));
       
   572       }
       
   573 
       
   574       EdgeIt(const Graph& _graph, const Edge& edge) 
       
   575 	: Edge(edge), graph(&_graph) { }
       
   576     
       
   577       EdgeIt& operator++() { 
       
   578 	graph->next(*this);
       
   579 	return *this; 
       
   580       }
       
   581 
       
   582     };
       
   583 
       
   584     class UEdgeIt : public UEdge { 
       
   585       friend class BpUGraphAdaptorExtender;
       
   586       const Graph* graph;
       
   587     public:
       
   588     
       
   589       UEdgeIt() { }
       
   590     
       
   591       UEdgeIt(Invalid i) : UEdge(INVALID) { }
       
   592     
       
   593       explicit UEdgeIt(const Graph& _graph) : graph(&_graph) {
       
   594 	graph->first(static_cast<UEdge&>(*this));
       
   595       }
       
   596 
       
   597       UEdgeIt(const Graph& _graph, const UEdge& edge) 
       
   598 	: UEdge(edge), graph(&_graph) { }
       
   599     
       
   600       UEdgeIt& operator++() { 
       
   601 	graph->next(*this);
       
   602 	return *this; 
       
   603       }
       
   604     };
       
   605 
       
   606     class OutEdgeIt : public Edge { 
       
   607       friend class BpUGraphAdaptorExtender;
       
   608       const Graph* graph;
       
   609     public:
       
   610     
       
   611       OutEdgeIt() { }
       
   612     
       
   613       OutEdgeIt(Invalid i) : Edge(i) { }
       
   614     
       
   615       OutEdgeIt(const Graph& _graph, const Node& node) 
       
   616 	: graph(&_graph) {
       
   617 	graph->firstOut(*this, node);
       
   618       }
       
   619     
       
   620       OutEdgeIt(const Graph& _graph, const Edge& edge) 
       
   621 	: Edge(edge), graph(&_graph) {}
       
   622     
       
   623       OutEdgeIt& operator++() { 
       
   624 	graph->nextOut(*this);
       
   625 	return *this; 
       
   626       }
       
   627 
       
   628     };
       
   629 
       
   630 
       
   631     class InEdgeIt : public Edge { 
       
   632       friend class BpUGraphAdaptorExtender;
       
   633       const Graph* graph;
       
   634     public:
       
   635     
       
   636       InEdgeIt() { }
       
   637     
       
   638       InEdgeIt(Invalid i) : Edge(i) { }
       
   639     
       
   640       InEdgeIt(const Graph& _graph, const Node& node) 
       
   641 	: graph(&_graph) {
       
   642 	graph->firstIn(*this, node);
       
   643       }
       
   644     
       
   645       InEdgeIt(const Graph& _graph, const Edge& edge) : 
       
   646 	Edge(edge), graph(&_graph) {}
       
   647     
       
   648       InEdgeIt& operator++() { 
       
   649 	graph->nextIn(*this);
       
   650 	return *this; 
       
   651       }
       
   652 
       
   653     };
       
   654   
       
   655     /// \brief Base node of the iterator
       
   656     ///
       
   657     /// Returns the base node (ie. the source in this case) of the iterator
       
   658     Node baseNode(const OutEdgeIt &e) const {
       
   659       return Parent::source((Edge&)e);
       
   660     }
       
   661     /// \brief Running node of the iterator
       
   662     ///
       
   663     /// Returns the running node (ie. the target in this case) of the
       
   664     /// iterator
       
   665     Node runningNode(const OutEdgeIt &e) const {
       
   666       return Parent::target((Edge&)e);
       
   667     }
       
   668   
       
   669     /// \brief Base node of the iterator
       
   670     ///
       
   671     /// Returns the base node (ie. the target in this case) of the iterator
       
   672     Node baseNode(const InEdgeIt &e) const {
       
   673       return Parent::target((Edge&)e);
       
   674     }
       
   675     /// \brief Running node of the iterator
       
   676     ///
       
   677     /// Returns the running node (ie. the source in this case) of the
       
   678     /// iterator
       
   679     Node runningNode(const InEdgeIt &e) const {
       
   680       return Parent::source((Edge&)e);
       
   681     }
       
   682   
       
   683     class IncEdgeIt : public Parent::UEdge { 
       
   684       friend class BpUGraphAdaptorExtender;
       
   685       const Graph* graph;
       
   686       bool direction;
       
   687     public:
       
   688     
       
   689       IncEdgeIt() { }
       
   690     
       
   691       IncEdgeIt(Invalid i) : UEdge(i), direction(true) { }
       
   692     
       
   693       IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
       
   694 	graph->firstInc(*this, direction, n);
       
   695       }
       
   696 
       
   697       IncEdgeIt(const Graph& _graph, const UEdge &ue, const Node &n)
       
   698 	: graph(&_graph), UEdge(ue) {
       
   699 	direction = (graph->source(ue) == n);
       
   700       }
       
   701 
       
   702       IncEdgeIt& operator++() {
       
   703 	graph->nextInc(*this, direction);
       
   704 	return *this; 
       
   705       }
       
   706     };
       
   707   
       
   708 
       
   709     /// Base node of the iterator
       
   710     ///
       
   711     /// Returns the base node of the iterator
       
   712     Node baseNode(const IncEdgeIt &e) const {
       
   713       return e.direction ? source(e) : target(e);
       
   714     }
       
   715 
       
   716     /// Running node of the iterator
       
   717     ///
       
   718     /// Returns the running node of the iterator
       
   719     Node runningNode(const IncEdgeIt &e) const {
       
   720       return e.direction ? target(e) : source(e);
       
   721     }
       
   722 
       
   723   };
       
   724 
   439 
   725 
   440 }
   726 }
   441 
   727 
   442 
   728 
   443 #endif
   729 #endif