deba@1979: /* -*- C++ -*- deba@1979: * deba@1979: * This file is a part of LEMON, a generic C++ optimization library deba@1979: * alpar@2553: * Copyright (C) 2003-2008 deba@1979: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport deba@1979: * (Egervary Research Group on Combinatorial Optimization, EGRES). deba@1979: * deba@1979: * Permission to use, modify and distribute this software is granted deba@1979: * provided that this copyright notice appears in all copies. For deba@1979: * precise terms see the accompanying LICENSE file. deba@1979: * deba@1979: * This software is provided "AS IS" with no warranty of any kind, deba@1979: * express or implied, and with no claim as to its suitability for any deba@1979: * purpose. deba@1979: * deba@1979: */ deba@1979: deba@1996: #ifndef LEMON_BITS_GRAPH_ADAPTOR_EXTENDER_H deba@1996: #define LEMON_BITS_GRAPH_ADAPTOR_EXTENDER_H deba@1979: deba@1996: #include deba@1996: #include deba@1979: deba@1996: #include deba@1996: deba@1996: deba@1996: ///\ingroup graphbits deba@1996: ///\file deba@1996: ///\brief Extenders for the graph adaptor types deba@1979: namespace lemon { deba@1979: deba@1996: /// \ingroup graphbits deba@1996: /// deba@1996: /// \brief Extender for the GraphAdaptors deba@2031: template deba@2031: class GraphAdaptorExtender : public _Graph { deba@1979: public: deba@1979: deba@2031: typedef _Graph Parent; deba@2031: typedef _Graph Graph; deba@2031: typedef GraphAdaptorExtender Adaptor; deba@1979: deba@1979: // Base extensions deba@1979: deba@1979: typedef typename Parent::Node Node; deba@1979: typedef typename Parent::Edge Edge; deba@1979: deba@1979: int maxId(Node) const { deba@1979: return Parent::maxNodeId(); deba@1979: } deba@1979: deba@1979: int maxId(Edge) const { deba@1979: return Parent::maxEdgeId(); deba@1979: } deba@1979: deba@1979: Node fromId(int id, Node) const { deba@1979: return Parent::nodeFromId(id); deba@1979: } deba@1979: deba@1979: Edge fromId(int id, Edge) const { deba@1979: return Parent::edgeFromId(id); deba@1979: } deba@1979: deba@1979: Node oppositeNode(const Node &n, const Edge &e) const { deba@1979: if (n == Parent::source(e)) deba@1979: return Parent::target(e); deba@1979: else if(n==Parent::target(e)) deba@1979: return Parent::source(e); deba@1979: else deba@1979: return INVALID; deba@1979: } deba@1979: deba@1979: class NodeIt : public Node { deba@2031: const Adaptor* graph; deba@1979: public: deba@1979: deba@1979: NodeIt() {} deba@1979: deba@1979: NodeIt(Invalid i) : Node(i) { } deba@1979: deba@2031: explicit NodeIt(const Adaptor& _graph) : graph(&_graph) { deba@2031: _graph.first(static_cast(*this)); deba@1979: } deba@1979: deba@2031: NodeIt(const Adaptor& _graph, const Node& node) deba@1979: : Node(node), graph(&_graph) {} deba@1979: deba@1979: NodeIt& operator++() { deba@1979: graph->next(*this); deba@1979: return *this; deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@1979: deba@1979: class EdgeIt : public Edge { deba@2031: const Adaptor* graph; deba@1979: public: deba@1979: deba@1979: EdgeIt() { } deba@1979: deba@1979: EdgeIt(Invalid i) : Edge(i) { } deba@1979: deba@2031: explicit EdgeIt(const Adaptor& _graph) : graph(&_graph) { deba@2031: _graph.first(static_cast(*this)); deba@1979: } deba@1979: deba@2031: EdgeIt(const Adaptor& _graph, const Edge& e) : deba@1979: Edge(e), graph(&_graph) { } deba@1979: deba@1979: EdgeIt& operator++() { deba@1979: graph->next(*this); deba@1979: return *this; deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@1979: deba@1979: class OutEdgeIt : public Edge { deba@2031: const Adaptor* graph; deba@1979: public: deba@1979: deba@1979: OutEdgeIt() { } deba@1979: deba@1979: OutEdgeIt(Invalid i) : Edge(i) { } deba@1979: deba@2031: OutEdgeIt(const Adaptor& _graph, const Node& node) deba@1979: : graph(&_graph) { deba@1979: _graph.firstOut(*this, node); deba@1979: } deba@1979: deba@2031: OutEdgeIt(const Adaptor& _graph, const Edge& edge) deba@1979: : Edge(edge), graph(&_graph) {} deba@1979: deba@1979: OutEdgeIt& operator++() { deba@1979: graph->nextOut(*this); deba@1979: return *this; deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@1979: deba@1979: class InEdgeIt : public Edge { deba@2031: const Adaptor* graph; deba@1979: public: deba@1979: deba@1979: InEdgeIt() { } deba@1979: deba@1979: InEdgeIt(Invalid i) : Edge(i) { } deba@1979: deba@2031: InEdgeIt(const Adaptor& _graph, const Node& node) deba@1979: : graph(&_graph) { deba@1979: _graph.firstIn(*this, node); deba@1979: } deba@1979: deba@2031: InEdgeIt(const Adaptor& _graph, const Edge& edge) : deba@1979: Edge(edge), graph(&_graph) {} deba@1979: deba@1979: InEdgeIt& operator++() { deba@1979: graph->nextIn(*this); deba@1979: return *this; deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@1979: /// \brief Base node of the iterator deba@1979: /// deba@1979: /// Returns the base node (ie. the source in this case) of the iterator deba@1979: Node baseNode(const OutEdgeIt &e) const { deba@1979: return Parent::source(e); deba@1979: } deba@1979: /// \brief Running node of the iterator deba@1979: /// deba@1979: /// Returns the running node (ie. the target in this case) of the deba@1979: /// iterator deba@1979: Node runningNode(const OutEdgeIt &e) const { deba@1979: return Parent::target(e); deba@1979: } deba@1979: deba@1979: /// \brief Base node of the iterator deba@1979: /// deba@1979: /// Returns the base node (ie. the target in this case) of the iterator deba@1979: Node baseNode(const InEdgeIt &e) const { deba@1979: return Parent::target(e); deba@1979: } deba@1979: /// \brief Running node of the iterator deba@1979: /// deba@1979: /// Returns the running node (ie. the source in this case) of the deba@1979: /// iterator deba@1979: Node runningNode(const InEdgeIt &e) const { deba@1979: return Parent::source(e); deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@1979: deba@1996: /// \ingroup graphbits deba@1996: /// deba@1996: /// \brief Extender for the UGraphAdaptors deba@2031: template deba@2031: class UGraphAdaptorExtender : public _UGraph { deba@1979: public: deba@1979: deba@2031: typedef _UGraph Parent; deba@2031: typedef _UGraph UGraph; deba@2031: typedef UGraphAdaptorExtender Adaptor; deba@1979: deba@1979: typedef typename Parent::Node Node; deba@1979: typedef typename Parent::Edge Edge; deba@1979: typedef typename Parent::UEdge UEdge; deba@1979: deba@1979: // UGraph extension deba@1979: deba@1979: int maxId(Node) const { deba@1979: return Parent::maxNodeId(); deba@1979: } deba@1979: deba@1979: int maxId(Edge) const { deba@1979: return Parent::maxEdgeId(); deba@1979: } deba@1979: deba@1979: int maxId(UEdge) const { deba@1979: return Parent::maxUEdgeId(); deba@1979: } deba@1979: deba@1979: Node fromId(int id, Node) const { deba@1979: return Parent::nodeFromId(id); deba@1979: } deba@1979: deba@1979: Edge fromId(int id, Edge) const { deba@1979: return Parent::edgeFromId(id); deba@1979: } deba@1979: deba@1979: UEdge fromId(int id, UEdge) const { deba@1979: return Parent::uEdgeFromId(id); deba@1979: } deba@1979: deba@1979: Node oppositeNode(const Node &n, const UEdge &e) const { deba@1979: if( n == Parent::source(e)) deba@1979: return Parent::target(e); deba@1979: else if( n == Parent::target(e)) deba@1979: return Parent::source(e); deba@1979: else deba@1979: return INVALID; deba@1979: } deba@1979: deba@1979: Edge oppositeEdge(const Edge &e) const { deba@1979: return Parent::direct(e, !Parent::direction(e)); deba@1979: } deba@1979: deba@1979: using Parent::direct; deba@1979: Edge direct(const UEdge &ue, const Node &s) const { deba@1979: return Parent::direct(ue, Parent::source(ue) == s); deba@1979: } deba@1979: deba@1979: deba@1979: class NodeIt : public Node { deba@2031: const Adaptor* graph; deba@1979: public: deba@1979: deba@1979: NodeIt() {} deba@1979: deba@1979: NodeIt(Invalid i) : Node(i) { } deba@1979: deba@2031: explicit NodeIt(const Adaptor& _graph) : graph(&_graph) { deba@2031: _graph.first(static_cast(*this)); deba@1979: } deba@1979: deba@2031: NodeIt(const Adaptor& _graph, const Node& node) deba@1979: : Node(node), graph(&_graph) {} deba@1979: deba@1979: NodeIt& operator++() { deba@1979: graph->next(*this); deba@1979: return *this; deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@1979: deba@1979: class EdgeIt : public Edge { deba@2031: const Adaptor* graph; deba@1979: public: deba@1979: deba@1979: EdgeIt() { } deba@1979: deba@1979: EdgeIt(Invalid i) : Edge(i) { } deba@1979: deba@2031: explicit EdgeIt(const Adaptor& _graph) : graph(&_graph) { deba@2031: _graph.first(static_cast(*this)); deba@1979: } deba@1979: deba@2031: EdgeIt(const Adaptor& _graph, const Edge& e) : deba@1979: Edge(e), graph(&_graph) { } deba@1979: deba@1979: EdgeIt& operator++() { deba@1979: graph->next(*this); deba@1979: return *this; deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@1979: deba@1979: class OutEdgeIt : public Edge { deba@2031: const Adaptor* graph; deba@1979: public: deba@1979: deba@1979: OutEdgeIt() { } deba@1979: deba@1979: OutEdgeIt(Invalid i) : Edge(i) { } deba@1979: deba@2031: OutEdgeIt(const Adaptor& _graph, const Node& node) deba@1979: : graph(&_graph) { deba@1979: _graph.firstOut(*this, node); deba@1979: } deba@1979: deba@2031: OutEdgeIt(const Adaptor& _graph, const Edge& edge) deba@1979: : Edge(edge), graph(&_graph) {} deba@1979: deba@1979: OutEdgeIt& operator++() { deba@1979: graph->nextOut(*this); deba@1979: return *this; deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@1979: deba@1979: class InEdgeIt : public Edge { deba@2031: const Adaptor* graph; deba@1979: public: deba@1979: deba@1979: InEdgeIt() { } deba@1979: deba@1979: InEdgeIt(Invalid i) : Edge(i) { } deba@1979: deba@2031: InEdgeIt(const Adaptor& _graph, const Node& node) deba@1979: : graph(&_graph) { deba@1979: _graph.firstIn(*this, node); deba@1979: } deba@1979: deba@2031: InEdgeIt(const Adaptor& _graph, const Edge& edge) : deba@1979: Edge(edge), graph(&_graph) {} deba@1979: deba@1979: InEdgeIt& operator++() { deba@1979: graph->nextIn(*this); deba@1979: return *this; deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@1979: class UEdgeIt : public Parent::UEdge { deba@2031: const Adaptor* graph; deba@1979: public: deba@1979: deba@1979: UEdgeIt() { } deba@1979: deba@1979: UEdgeIt(Invalid i) : UEdge(i) { } deba@1979: deba@2031: explicit UEdgeIt(const Adaptor& _graph) : graph(&_graph) { deba@2031: _graph.first(static_cast(*this)); deba@1979: } deba@1979: deba@2031: UEdgeIt(const Adaptor& _graph, const UEdge& e) : deba@1979: UEdge(e), graph(&_graph) { } deba@1979: deba@1979: UEdgeIt& operator++() { deba@1979: graph->next(*this); deba@1979: return *this; deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@1979: class IncEdgeIt : public Parent::UEdge { deba@1979: friend class UGraphAdaptorExtender; deba@2031: const Adaptor* graph; deba@1979: bool direction; deba@1979: public: deba@1979: deba@1979: IncEdgeIt() { } deba@1979: deba@1979: IncEdgeIt(Invalid i) : UEdge(i), direction(false) { } deba@1979: deba@2031: IncEdgeIt(const Adaptor& _graph, const Node &n) : graph(&_graph) { deba@1979: _graph.firstInc(static_cast(*this), direction, n); deba@1979: } deba@1979: deba@2031: IncEdgeIt(const Adaptor& _graph, const UEdge &ue, const Node &n) deba@1979: : graph(&_graph), UEdge(ue) { deba@1979: direction = (_graph.source(ue) == n); deba@1979: } deba@1979: deba@1979: IncEdgeIt& operator++() { deba@1979: graph->nextInc(*this, direction); deba@1979: return *this; deba@1979: } deba@1979: }; deba@1979: deba@1979: /// \brief Base node of the iterator deba@1979: /// deba@1979: /// Returns the base node (ie. the source in this case) of the iterator deba@1979: Node baseNode(const OutEdgeIt &e) const { deba@2386: return Parent::source(static_cast(e)); deba@1979: } deba@1979: /// \brief Running node of the iterator deba@1979: /// deba@1979: /// Returns the running node (ie. the target in this case) of the deba@1979: /// iterator deba@1979: Node runningNode(const OutEdgeIt &e) const { deba@2386: return Parent::target(static_cast(e)); deba@1979: } deba@1979: deba@1979: /// \brief Base node of the iterator deba@1979: /// deba@1979: /// Returns the base node (ie. the target in this case) of the iterator deba@1979: Node baseNode(const InEdgeIt &e) const { deba@2386: return Parent::target(static_cast(e)); deba@1979: } deba@1979: /// \brief Running node of the iterator deba@1979: /// deba@1979: /// Returns the running node (ie. the source in this case) of the deba@1979: /// iterator deba@1979: Node runningNode(const InEdgeIt &e) const { deba@2386: return Parent::source(static_cast(e)); deba@1979: } deba@1979: deba@1979: /// Base node of the iterator deba@1979: /// deba@1979: /// Returns the base node of the iterator deba@1979: Node baseNode(const IncEdgeIt &e) const { deba@1979: return e.direction ? source(e) : target(e); deba@1979: } deba@1979: /// Running node of the iterator deba@1979: /// deba@1979: /// Returns the running node of the iterator deba@1979: Node runningNode(const IncEdgeIt &e) const { deba@1979: return e.direction ? target(e) : source(e); deba@1979: } deba@1979: deba@1979: }; deba@1979: deba@2031: /// \ingroup graphbits deba@2031: /// deba@2031: /// \brief Extender for the BpUGraphAdaptors deba@2031: template deba@2031: class BpUGraphAdaptorExtender : public Base { deba@2031: public: deba@2031: typedef Base Parent; deba@2031: typedef BpUGraphAdaptorExtender Graph; deba@2031: deba@2031: typedef typename Parent::Node Node; deba@2031: typedef typename Parent::BNode BNode; deba@2031: typedef typename Parent::ANode ANode; deba@2031: typedef typename Parent::Edge Edge; deba@2031: typedef typename Parent::UEdge UEdge; deba@2031: deba@2031: deba@2031: int maxId(Node) const { deba@2031: return Parent::maxNodeId(); deba@2031: } deba@2031: int maxId(BNode) const { deba@2031: return Parent::maxBNodeId(); deba@2031: } deba@2031: int maxId(ANode) const { deba@2031: return Parent::maxANodeId(); deba@2031: } deba@2031: int maxId(Edge) const { deba@2031: return Parent::maxEdgeId(); deba@2031: } deba@2031: int maxId(UEdge) const { deba@2031: return Parent::maxUEdgeId(); deba@2031: } deba@2031: deba@2031: deba@2031: Node fromId(int id, Node) const { deba@2031: return Parent::nodeFromId(id); deba@2031: } deba@2031: ANode fromId(int id, ANode) const { deba@2231: return Parent::nodeFromANodeId(id); deba@2031: } deba@2031: BNode fromId(int id, BNode) const { deba@2231: return Parent::nodeFromBNodeId(id); deba@2031: } deba@2031: Edge fromId(int id, Edge) const { deba@2031: return Parent::edgeFromId(id); deba@2031: } deba@2031: UEdge fromId(int id, UEdge) const { deba@2031: return Parent::uEdgeFromId(id); deba@2031: } deba@2031: deba@2031: class NodeIt : public Node { deba@2031: const Graph* graph; deba@2031: public: deba@2031: deba@2031: NodeIt() { } deba@2031: deba@2031: NodeIt(Invalid i) : Node(INVALID) { } deba@2031: deba@2031: explicit NodeIt(const Graph& _graph) : graph(&_graph) { deba@2031: graph->first(static_cast(*this)); deba@2031: } deba@2031: deba@2031: NodeIt(const Graph& _graph, const Node& node) deba@2031: : Node(node), graph(&_graph) { } deba@2031: deba@2031: NodeIt& operator++() { deba@2031: graph->next(*this); deba@2031: return *this; deba@2031: } deba@2031: deba@2031: }; deba@2031: deba@2031: class ANodeIt : public Node { deba@2031: friend class BpUGraphAdaptorExtender; deba@2031: const Graph* graph; deba@2031: public: deba@2031: deba@2031: ANodeIt() { } deba@2031: deba@2031: ANodeIt(Invalid i) : Node(INVALID) { } deba@2031: deba@2031: explicit ANodeIt(const Graph& _graph) : graph(&_graph) { deba@2031: graph->firstANode(static_cast(*this)); deba@2031: } deba@2031: deba@2031: ANodeIt(const Graph& _graph, const Node& node) deba@2031: : Node(node), graph(&_graph) {} deba@2031: deba@2031: ANodeIt& operator++() { deba@2031: graph->nextANode(*this); deba@2031: return *this; deba@2031: } deba@2031: }; deba@2031: deba@2031: class BNodeIt : public Node { deba@2031: friend class BpUGraphAdaptorExtender; deba@2031: const Graph* graph; deba@2031: public: deba@2031: deba@2031: BNodeIt() { } deba@2031: deba@2031: BNodeIt(Invalid i) : Node(INVALID) { } deba@2031: deba@2031: explicit BNodeIt(const Graph& _graph) : graph(&_graph) { deba@2031: graph->firstBNode(static_cast(*this)); deba@2031: } deba@2031: deba@2031: BNodeIt(const Graph& _graph, const Node& node) deba@2031: : Node(node), graph(&_graph) {} deba@2031: deba@2031: BNodeIt& operator++() { deba@2031: graph->nextBNode(*this); deba@2031: return *this; deba@2031: } deba@2031: }; deba@2031: deba@2031: class EdgeIt : public Edge { deba@2031: friend class BpUGraphAdaptorExtender; deba@2031: const Graph* graph; deba@2031: public: deba@2031: deba@2031: EdgeIt() { } deba@2031: deba@2031: EdgeIt(Invalid i) : Edge(INVALID) { } deba@2031: deba@2031: explicit EdgeIt(const Graph& _graph) : graph(&_graph) { deba@2031: graph->first(static_cast(*this)); deba@2031: } deba@2031: deba@2031: EdgeIt(const Graph& _graph, const Edge& edge) deba@2031: : Edge(edge), graph(&_graph) { } deba@2031: deba@2031: EdgeIt& operator++() { deba@2031: graph->next(*this); deba@2031: return *this; deba@2031: } deba@2031: deba@2031: }; deba@2031: deba@2031: class UEdgeIt : public UEdge { deba@2031: friend class BpUGraphAdaptorExtender; deba@2031: const Graph* graph; deba@2031: public: deba@2031: deba@2031: UEdgeIt() { } deba@2031: deba@2031: UEdgeIt(Invalid i) : UEdge(INVALID) { } deba@2031: deba@2031: explicit UEdgeIt(const Graph& _graph) : graph(&_graph) { deba@2031: graph->first(static_cast(*this)); deba@2031: } deba@2031: deba@2031: UEdgeIt(const Graph& _graph, const UEdge& edge) deba@2031: : UEdge(edge), graph(&_graph) { } deba@2031: deba@2031: UEdgeIt& operator++() { deba@2031: graph->next(*this); deba@2031: return *this; deba@2031: } deba@2031: }; deba@2031: deba@2031: class OutEdgeIt : public Edge { deba@2031: friend class BpUGraphAdaptorExtender; deba@2031: const Graph* graph; deba@2031: public: deba@2031: deba@2031: OutEdgeIt() { } deba@2031: deba@2031: OutEdgeIt(Invalid i) : Edge(i) { } deba@2031: deba@2031: OutEdgeIt(const Graph& _graph, const Node& node) deba@2031: : graph(&_graph) { deba@2031: graph->firstOut(*this, node); deba@2031: } deba@2031: deba@2031: OutEdgeIt(const Graph& _graph, const Edge& edge) deba@2031: : Edge(edge), graph(&_graph) {} deba@2031: deba@2031: OutEdgeIt& operator++() { deba@2031: graph->nextOut(*this); deba@2031: return *this; deba@2031: } deba@2031: deba@2031: }; deba@2031: deba@2031: deba@2031: class InEdgeIt : public Edge { deba@2031: friend class BpUGraphAdaptorExtender; deba@2031: const Graph* graph; deba@2031: public: deba@2031: deba@2031: InEdgeIt() { } deba@2031: deba@2031: InEdgeIt(Invalid i) : Edge(i) { } deba@2031: deba@2031: InEdgeIt(const Graph& _graph, const Node& node) deba@2031: : graph(&_graph) { deba@2031: graph->firstIn(*this, node); deba@2031: } deba@2031: deba@2031: InEdgeIt(const Graph& _graph, const Edge& edge) : deba@2031: Edge(edge), graph(&_graph) {} deba@2031: deba@2031: InEdgeIt& operator++() { deba@2031: graph->nextIn(*this); deba@2031: return *this; deba@2031: } deba@2031: deba@2031: }; deba@2031: deba@2031: /// \brief Base node of the iterator deba@2031: /// deba@2031: /// Returns the base node (ie. the source in this case) of the iterator deba@2031: Node baseNode(const OutEdgeIt &e) const { deba@2386: return Parent::source(static_cast(e)); deba@2031: } deba@2031: /// \brief Running node of the iterator deba@2031: /// deba@2031: /// Returns the running node (ie. the target in this case) of the deba@2031: /// iterator deba@2031: Node runningNode(const OutEdgeIt &e) const { deba@2386: return Parent::target(static_cast(e)); deba@2031: } deba@2031: deba@2031: /// \brief Base node of the iterator deba@2031: /// deba@2031: /// Returns the base node (ie. the target in this case) of the iterator deba@2031: Node baseNode(const InEdgeIt &e) const { deba@2386: return Parent::target(static_cast(e)); deba@2031: } deba@2031: /// \brief Running node of the iterator deba@2031: /// deba@2031: /// Returns the running node (ie. the source in this case) of the deba@2031: /// iterator deba@2031: Node runningNode(const InEdgeIt &e) const { deba@2386: return Parent::source(static_cast(e)); deba@2031: } deba@2031: deba@2031: class IncEdgeIt : public Parent::UEdge { deba@2031: friend class BpUGraphAdaptorExtender; deba@2031: const Graph* graph; deba@2031: bool direction; deba@2031: public: deba@2031: deba@2031: IncEdgeIt() { } deba@2031: deba@2031: IncEdgeIt(Invalid i) : UEdge(i), direction(true) { } deba@2031: deba@2031: IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) { deba@2031: graph->firstInc(*this, direction, n); deba@2031: } deba@2031: deba@2031: IncEdgeIt(const Graph& _graph, const UEdge &ue, const Node &n) deba@2031: : graph(&_graph), UEdge(ue) { deba@2031: direction = (graph->source(ue) == n); deba@2031: } deba@2031: deba@2031: IncEdgeIt& operator++() { deba@2031: graph->nextInc(*this, direction); deba@2031: return *this; deba@2031: } deba@2031: }; deba@2031: deba@2031: deba@2031: /// Base node of the iterator deba@2031: /// deba@2031: /// Returns the base node of the iterator deba@2031: Node baseNode(const IncEdgeIt &e) const { deba@2031: return e.direction ? source(e) : target(e); deba@2031: } deba@2031: deba@2031: /// Running node of the iterator deba@2031: /// deba@2031: /// Returns the running node of the iterator deba@2031: Node runningNode(const IncEdgeIt &e) const { deba@2031: return e.direction ? target(e) : source(e); deba@2031: } deba@2031: deba@2041: Node oppositeNode(const Node &n, const UEdge &e) const { deba@2041: if( n == Parent::source(e)) deba@2041: return Parent::target(e); deba@2041: else if( n == Parent::target(e)) deba@2041: return Parent::source(e); deba@2041: else deba@2041: return INVALID; deba@2041: } deba@2041: deba@2041: Edge oppositeEdge(const Edge &e) const { deba@2041: return Parent::direct(e, !Parent::direction(e)); deba@2041: } deba@2041: deba@2041: using Parent::direct; deba@2041: Edge direct(const UEdge &ue, const Node &s) const { deba@2041: return Parent::direct(ue, Parent::source(ue) == s); deba@2041: } deba@2041: deba@2031: }; deba@2031: deba@1979: deba@1979: } deba@1979: deba@1979: deba@1979: #endif