src/lemon/undir_graph_extender.h
changeset 1087 d496d1d5a5e7
parent 1054 6a62b1b4cf23
child 1158 29961fa390a3
equal deleted inserted replaced
7:50d8c28149cc 8:20ea7c9e0e15
   138     
   138     
   139   protected:
   139   protected:
   140 
   140 
   141     template <typename E>
   141     template <typename E>
   142     void _dirFirstOut(E &e, const Node &n) const {
   142     void _dirFirstOut(E &e, const Node &n) const {
       
   143       Parent::firstIn(e,n);
       
   144       if( UndirEdge(e) != INVALID ) {
       
   145 	e.forward = false;
       
   146       }
       
   147       else {
       
   148 	Parent::firstOut(e,n);
       
   149 	e.forward = true;
       
   150       }
       
   151     }
       
   152     template <typename E>
       
   153     void _dirFirstIn(E &e, const Node &n) const {
   143       Parent::firstOut(e,n);
   154       Parent::firstOut(e,n);
   144       if( UndirEdge(e) != INVALID ) {
   155       if( UndirEdge(e) != INVALID ) {
       
   156 	e.forward = false;
       
   157       }
       
   158       else {
       
   159 	Parent::firstIn(e,n);
   145 	e.forward = true;
   160 	e.forward = true;
   146       }
   161       }
   147       else {
       
   148 	Parent::firstIn(e,n);
       
   149 	e.forward = false;
       
   150       }
       
   151     }
       
   152     template <typename E>
       
   153     void _dirFirstIn(E &e, const Node &n) const {
       
   154       Parent::firstIn(e,n);
       
   155       if( UndirEdge(e) != INVALID ) {
       
   156 	e.forward = true;
       
   157       }
       
   158       else {
       
   159 	Parent::firstOut(e,n);
       
   160 	e.forward = false;
       
   161       }
       
   162     }
   162     }
   163 
   163 
   164     template <typename E>
   164     template <typename E>
   165     void _dirNextOut(E &e) const {
   165     void _dirNextOut(E &e) const {
   166       if( e.forward ) {
   166       if( ! e.forward ) {
       
   167 	Node n = Parent::target(e);
       
   168 	Parent::nextIn(e);
       
   169 	if( UndirEdge(e) == INVALID ) {
       
   170 	  Parent::firstOut(e, n);
       
   171 	  e.forward = true;
       
   172 	}
       
   173       }
       
   174       else {
       
   175 	Parent::nextOut(e);
       
   176       }
       
   177     }
       
   178     template <typename E>
       
   179     void _dirNextIn(E &e) const {
       
   180       if( ! e.forward ) {
       
   181 	Node n = Parent::source(e);
   167 	Parent::nextOut(e);
   182 	Parent::nextOut(e);
   168 	if( UndirEdge(e) == INVALID ) {
   183 	if( UndirEdge(e) == INVALID ) {
   169 	  Parent::firstIn(e, Parent::source(e));
   184 	  Parent::firstIn(e, n);
   170 	  e.forward = false;
   185 	  e.forward = true;
   171 	}
   186 	}
   172       }
   187       }
   173       else {
   188       else {
   174 	Parent::nextIn(e);
   189 	Parent::nextIn(e);
   175       }
       
   176     }
       
   177     template <typename E>
       
   178     void _dirNextIn(E &e) const {
       
   179       if( e.forward ) {
       
   180 	Parent::nextIn(e);
       
   181 	if( UndirEdge(e) == INVALID ) {
       
   182 	  Parent::firstOut(e, Parent::target(e));
       
   183 	  e.forward = false;
       
   184 	}
       
   185       }
       
   186       else {
       
   187 	Parent::nextOut(e);
       
   188       }
   190       }
   189     }
   191     }
   190 
   192 
   191   public:
   193   public:
   192 
   194 
   224     int id(const Edge &e) const {
   226     int id(const Edge &e) const {
   225       return 2 * Parent::id(e) + int(e.forward);
   227       return 2 * Parent::id(e) + int(e.forward);
   226     }
   228     }
   227 
   229 
   228 
   230 
   229     int maxId(Node n) const {
   231     int maxId(Node) const {
   230       return Parent::maxId(Node());
   232       return Parent::maxId(Node());
   231     }
   233     }
   232 
   234 
   233     int maxId(Edge) const {
   235     int maxId(Edge) const {
   234       return 2 * Parent::maxId(typename Parent::Edge()) + 1;
   236       return 2 * Parent::maxId(typename Parent::Edge()) + 1;