lemon/graph_utils.h
changeset 196 420013ff029b
parent 157 2ccc1afc2c52
child 199 e3aba2c72be4
equal deleted inserted replaced
5:2577e0b9d8ec 6:dd5959d7af48
   400         bool b;
   400         bool b;
   401         if (u != v) {
   401         if (u != v) {
   402           if (e == INVALID) {
   402           if (e == INVALID) {
   403             g.firstInc(e, b, u);
   403             g.firstInc(e, b, u);
   404           } else {
   404           } else {
   405             b = g.source(e) == u;
   405             b = g.u(e) == u;
   406             g.nextInc(e, b);
   406             g.nextInc(e, b);
   407           }
   407           }
   408           while (e != INVALID && (b ? g.target(e) : g.source(e)) != v) {
   408           while (e != INVALID && (b ? g.v(e) : g.u(e)) != v) {
   409             g.nextInc(e, b);
   409             g.nextInc(e, b);
   410           }
   410           }
   411         } else {
   411         } else {
   412           if (e == INVALID) {
   412           if (e == INVALID) {
   413             g.firstInc(e, b, u);
   413             g.firstInc(e, b, u);
   414           } else {
   414           } else {
   415             b = true;
   415             b = true;
   416             g.nextInc(e, b);
   416             g.nextInc(e, b);
   417           }
   417           }
   418           while (e != INVALID && (!b || g.target(e) != v)) {
   418           while (e != INVALID && (!b || g.v(e) != v)) {
   419             g.nextInc(e, b);
   419             g.nextInc(e, b);
   420           }
   420           }
   421         }
   421         }
   422         return e;
   422         return e;
   423       }
   423       }
   453   ///     e = findEdge(g,u,v,e)) {
   453   ///     e = findEdge(g,u,v,e)) {
   454   ///   ...
   454   ///   ...
   455   /// }
   455   /// }
   456   ///\endcode
   456   ///\endcode
   457   ///
   457   ///
   458   ///\sa ConArcIt
   458   ///\sa ConEdgeIt
   459 
   459 
   460   template <typename Graph>
   460   template <typename Graph>
   461   inline typename Graph::Edge 
   461   inline typename Graph::Edge 
   462   findEdge(const Graph &g, typename Graph::Node u, typename Graph::Node v,
   462   findEdge(const Graph &g, typename Graph::Node u, typename Graph::Node v,
   463             typename Graph::Edge p = INVALID) {
   463             typename Graph::Edge p = INVALID) {
   502     
   502     
   503     /// \brief Increment operator.
   503     /// \brief Increment operator.
   504     ///
   504     ///
   505     /// It increments the iterator and gives back the next edge.
   505     /// It increments the iterator and gives back the next edge.
   506     ConEdgeIt& operator++() {
   506     ConEdgeIt& operator++() {
   507       Parent::operator=(findEdge(_graph, _graph.source(*this), 
   507       Parent::operator=(findEdge(_graph, _graph.u(*this), 
   508 				 _graph.target(*this), *this));
   508 				 _graph.v(*this), *this));
   509       return *this;
   509       return *this;
   510     }
   510     }
   511   private:
   511   private:
   512     const Graph& _graph;
   512     const Graph& _graph;
   513   };
   513   };