lemon/bits/iterable_graph_extender.h
changeset 1681 84e43c7ca1e3
parent 1564 16d316199cf6
child 1704 467d7927a901
equal deleted inserted replaced
2:7c80b6b09221 3:57ad33aca0cf
   116 	return *this; 
   116 	return *this; 
   117       }
   117       }
   118 
   118 
   119     };
   119     };
   120 
   120 
   121     /// Base node of the iterator
   121     /// \brief Base node of the iterator
   122     ///
   122     ///
   123     /// Returns the base node (ie. the source in this case) of the iterator
   123     /// Returns the base node (ie. the source in this case) of the iterator
   124     ///
       
   125     /// \todo Document in the concept!
       
   126     Node baseNode(const OutEdgeIt &e) const {
   124     Node baseNode(const OutEdgeIt &e) const {
   127       return Parent::source((Edge)e);
   125       return Parent::source((Edge)e);
   128     }
   126     }
   129     /// Running node of the iterator
   127     /// \brief Running node of the iterator
   130     ///
   128     ///
   131     /// Returns the running node (ie. the target in this case) of the
   129     /// Returns the running node (ie. the target in this case) of the
   132     /// iterator
   130     /// iterator
   133     ///
       
   134     /// \todo Document in the concept!
       
   135     Node runningNode(const OutEdgeIt &e) const {
   131     Node runningNode(const OutEdgeIt &e) const {
   136       return Parent::target((Edge)e);
   132       return Parent::target((Edge)e);
   137     }
   133     }
   138 
   134 
   139     /// Base node of the iterator
   135     /// \brief Base node of the iterator
   140     ///
   136     ///
   141     /// Returns the base node (ie. the target in this case) of the iterator
   137     /// Returns the base node (ie. the target in this case) of the iterator
   142     ///
       
   143     /// \todo Document in the concept!
       
   144     Node baseNode(const InEdgeIt &e) const {
   138     Node baseNode(const InEdgeIt &e) const {
   145       return Parent::target((Edge)e);
   139       return Parent::target((Edge)e);
   146     }
   140     }
   147     /// Running node of the iterator
   141     /// \brief Running node of the iterator
   148     ///
   142     ///
   149     /// Returns the running node (ie. the source in this case) of the
   143     /// Returns the running node (ie. the source in this case) of the
   150     /// iterator
   144     /// iterator
   151     ///
       
   152     /// \todo Document in the concept!
       
   153     Node runningNode(const InEdgeIt &e) const {
   145     Node runningNode(const InEdgeIt &e) const {
   154       return Parent::source((Edge)e);
   146       return Parent::source((Edge)e);
   155     }
   147     }
   156 
   148 
   157     using Parent::first;
   149     using Parent::first;
   158 
   150 
       
   151     /// \brief The opposite node on the given edge.
       
   152     ///
       
   153     /// Gives back the opposite on the given edge.
       
   154     Node oppositeNode(const Node& n, const Edge& e) const {
       
   155       if (Parent::source(e) == n) {
       
   156 	return Parent::target(e);
       
   157       } else {
       
   158 	return Parent::source(e);
       
   159       }
       
   160     }
       
   161 
   159   private:
   162   private:
   160 
       
   161     // /// \todo When (and if) we change the iterators concept to use operator*,
       
   162     // /// then the following shadowed methods will become superfluous.
       
   163     // /// But for now these are important safety measures.
       
   164 
   163 
   165     // void first(NodeIt &) const;
   164     // void first(NodeIt &) const;
   166     // void first(EdgeIt &) const;
   165     // void first(EdgeIt &) const;
   167     // void first(OutEdgeIt &) const;
   166     // void first(OutEdgeIt &) const;
   168     // void first(InEdgeIt &) const;
   167     // void first(InEdgeIt &) const;
   188     typedef True UndirTag;
   187     typedef True UndirTag;
   189 
   188 
   190     typedef IterableGraphExtender<_Base> Parent;
   189     typedef IterableGraphExtender<_Base> Parent;
   191     typedef IterableUndirGraphExtender<_Base> Graph;
   190     typedef IterableUndirGraphExtender<_Base> Graph;
   192     typedef typename Parent::Node Node;
   191     typedef typename Parent::Node Node;
   193 
   192     typedef typename Parent::Edge Edge;
   194     typedef typename Parent::UndirEdge UndirEdge;
   193     typedef typename Parent::UndirEdge UndirEdge;
   195 
   194 
   196     class UndirEdgeIt : public Parent::UndirEdge { 
   195     class UndirEdgeIt : public Parent::UndirEdge { 
   197       const Graph* graph;
   196       const Graph* graph;
   198     public:
   197     public:
   259     /// Returns the running node of the iterator
   258     /// Returns the running node of the iterator
   260     Node runningNode(const IncEdgeIt &e) const {
   259     Node runningNode(const IncEdgeIt &e) const {
   261       return _dirTarget(e);
   260       return _dirTarget(e);
   262     }
   261     }
   263 
   262 
       
   263     /// \brief The opposite node on the given undirected edge.
       
   264     ///
       
   265     /// Gives back the opposite on the given undirected edge.
       
   266     Node oppositeNode(const Node& n, const UndirEdge& e) const {
       
   267       if (Parent::source(e) == n) {
       
   268 	return Parent::target(e);
       
   269       } else {
       
   270 	return Parent::source(e);
       
   271       }
       
   272     }
       
   273 
   264   };
   274   };
   265 }
   275 }
   266 
   276 
   267 #endif // LEMON_GRAPH_EXTENDER_H
   277 #endif // LEMON_GRAPH_EXTENDER_H