src/work/klao/path.h
changeset 484 13e57edac8ed
parent 434 1ce1b4cd8dd5
child 493 bbd1db03f0fe
equal deleted inserted replaced
4:0e8f2db5a516 5:ff2da362cbe6
   583   }
   583   }
   584 
   584 
   585   template<typename Gr>
   585   template<typename Gr>
   586   typename DynamicPath<Gr>::EdgeIt&
   586   typename DynamicPath<Gr>::EdgeIt&
   587   DynamicPath<Gr>::nth(EdgeIt &e, size_t k) const {
   587   DynamicPath<Gr>::nth(EdgeIt &e, size_t k) const {
   588     if( k<0 || k>=length() ) {
   588     if( k>=length() ) {
   589       // FIXME: invalid EdgeIt
   589       // FIXME: invalid EdgeIt
   590       e.it = edges.end();
   590       e.it = edges.end();
   591       e.forw = true;
   591       e.forw = true;
   592       return e;
   592       return e;
   593     }
   593     }
   604   }
   604   }
   605     
   605     
   606   template<typename Gr>
   606   template<typename Gr>
   607   typename DynamicPath<Gr>::NodeIt&
   607   typename DynamicPath<Gr>::NodeIt&
   608   DynamicPath<Gr>::nth(NodeIt &n, size_t k) const {
   608   DynamicPath<Gr>::nth(NodeIt &n, size_t k) const {
   609     if( k<0 || k>length() ) {
   609     if( k>length() ) {
   610       // FIXME: invalid NodeIt
   610       // FIXME: invalid NodeIt
   611       n.idx = length()+1;
   611       n.idx = length()+1;
   612       n.tail = true;
   612       n.tail = true;
   613       return n;
   613       return n;
   614     }
   614     }
   647     if( !P.valid(a) || !P.valid(b) )
   647     if( !P.valid(a) || !P.valid(b) )
   648       return;
   648       return;
   649 
   649 
   650     int ai = a.idx, bi = b.idx;
   650     int ai = a.idx, bi = b.idx;
   651     if( bi<ai )
   651     if( bi<ai )
   652       swap(ai,bi);
   652       std::swap(ai,bi);
   653     
   653     
   654     edges.resize(bi-ai);
   654     edges.resize(bi-ai);
   655     copy(P.edges.begin()+ai, P.edges.begin()+bi, edges.begin());
   655     copy(P.edges.begin()+ai, P.edges.begin()+bi, edges.begin());
   656 
   656 
   657     _first = P.graphNode(a);
   657     _first = P.graphNode(a);