src/lemon/iterable_graph_extender.h
changeset 1224 7f4f2855fa11
parent 1030 c8a41699e613
child 1230 daf41fe81728
equal deleted inserted replaced
4:8aceb7229828 5:a5d10914a05e
   108 	return *this; 
   108 	return *this; 
   109       }
   109       }
   110 
   110 
   111     };
   111     };
   112 
   112 
       
   113     /// Base node of the iterator
       
   114     ///
       
   115     /// Returns the base node (ie. the source in this case) of the iterator
       
   116     ///
       
   117     /// \todo Document in the concept!
       
   118     Node baseNode(const OutEdgeIt &e) const {
       
   119       return source(e);
       
   120     }
       
   121     /// Running node of the iterator
       
   122     ///
       
   123     /// Returns the running node (ie. the target in this case) of the
       
   124     /// iterator
       
   125     ///
       
   126     /// \todo Document in the concept!
       
   127     Node runningNode(const OutEdgeIt &e) const {
       
   128       return target(e);
       
   129     }
       
   130 
       
   131     /// Base node of the iterator
       
   132     ///
       
   133     /// Returns the base node (ie. the target in this case) of the iterator
       
   134     ///
       
   135     /// \todo Document in the concept!
       
   136     Node baseNode(const InEdgeIt &e) const {
       
   137       return target(e);
       
   138     }
       
   139     /// Running node of the iterator
       
   140     ///
       
   141     /// Returns the running node (ie. the source in this case) of the
       
   142     /// iterator
       
   143     ///
       
   144     /// \todo Document in the concept!
       
   145     Node runningNode(const InEdgeIt &e) const {
       
   146       return source(e);
       
   147     }
       
   148 
   113     using Parent::first;
   149     using Parent::first;
   114 
   150 
   115   private:
   151   private:
   116 
   152 
   117     /// \todo When (and if) we change the iterators concept to use operator*,
   153     /// \todo When (and if) we change the iterators concept to use operator*,
   122     void first(EdgeIt &) const;
   158     void first(EdgeIt &) const;
   123     void first(OutEdgeIt &) const;
   159     void first(OutEdgeIt &) const;
   124     void first(InEdgeIt &) const;
   160     void first(InEdgeIt &) const;
   125 
   161 
   126   };
   162   };
       
   163 
       
   164 
       
   165 
       
   166 
       
   167 
   127   
   168   
   128   template <typename _Base>
   169   template <typename _Base>
   129   class IterableUndirGraphExtender : public IterableGraphExtender<_Base> {
   170   class IterableUndirGraphExtender : public IterableGraphExtender<_Base> {
   130   public:
   171   public:
   131 
   172 
   167 
   208 
   168       IncEdgeIt() { }
   209       IncEdgeIt() { }
   169 
   210 
   170       IncEdgeIt(Invalid i) : UndirEdge(i), forward(false) { }
   211       IncEdgeIt(Invalid i) : UndirEdge(i), forward(false) { }
   171 
   212 
   172       explicit IncEdgeIt(const Graph& _graph, const Node &n)
   213       IncEdgeIt(const Graph& _graph, const Node &n)
   173 	: graph(&_graph)
   214 	: graph(&_graph)
   174       {
   215       {
   175 	_graph._dirFirstOut(*this, n);
   216 	_graph._dirFirstOut(*this, n);
   176       }
   217       }
   177 
   218 
   178       // FIXME: Do we need this type of constructor here?
   219       IncEdgeIt(const Graph& _graph, const UndirEdge &ue, const Node &n)
   179       // IncEdgeIt(const Graph& _graph, const Edge& e) : 
   220 	: graph(&_graph), UndirEdge(ue)
   180       //   UndirEdge(e), graph(&_graph), forward(_graph.forward(e)) { }
   221       {
   181       // or
   222 	forward = (_graph.source(ue) == n);
   182       // IncEdgeIt(const Graph& _graph, const Node& n,
   223       }
   183       //    Const UndirEdge &e) ... ?
       
   184 
   224 
   185       IncEdgeIt& operator++() {
   225       IncEdgeIt& operator++() {
   186 	graph->_dirNextOut(*this);
   226 	graph->_dirNextOut(*this);
   187 	return *this; 
   227 	return *this; 
   188       }
   228       }
   189     };
   229     };
   190 
   230 
   191     Node source(const IncEdgeIt &e) const {
   231     using Parent::baseNode;
       
   232     using Parent::runningNode;
       
   233 
       
   234     /// Base node of the iterator
       
   235     ///
       
   236     /// Returns the base node of the iterator
       
   237     Node baseNode(const IncEdgeIt &e) const {
   192       return _dirSource(e);
   238       return _dirSource(e);
   193     }
   239     }
   194 
   240     /// Running node of the iterator
   195     /// \todo Shouldn't the "source" of an undirected edge be called "aNode"
   241     ///
   196     /// or something???
   242     /// Returns the running node of the iterator
   197     using Parent::source;
   243     Node runningNode(const IncEdgeIt &e) const {
   198 
       
   199     /// Target of the given Edge.
       
   200     Node target(const IncEdgeIt &e) const {
       
   201       return _dirTarget(e);
   244       return _dirTarget(e);
   202     }
   245     }
   203 
       
   204     /// \todo Shouldn't the "target" of an undirected edge be called "bNode"
       
   205     /// or something???
       
   206     using Parent::target;
       
   207 
   246 
   208   };
   247   };
   209 }
   248 }
   210 
   249 
   211 #endif // LEMON_GRAPH_EXTENDER_H
   250 #endif // LEMON_GRAPH_EXTENDER_H