Changeset 226:616bc397c83a in lemon0.x for src/work/klao/path.h
 Timestamp:
 03/21/04 18:09:16 (17 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@323
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/work/klao/path.h
r225 r226 11 11 12 12 #include <deque> 13 #include <algorithm> 13 14 14 15 #include <invalid.h> … … 40 41 Path(Graph &_G) : G(_G), _first(INVALID), _last(INVALID) {} 41 42 42 /// Subpath defined by two nodes 43 Path(Path const& P, NodeIt a, NodeIt b) { FIXME; } 44 /// Subpath defined by tow edges. Contains edges in [a,b) 45 Path(Path const& P, EdgeIt a, EdgeIt b) { FIXME; } 43 /// Subpath defined by two nodes. 44 /// Nodes may be in reversed order, then 45 /// we contstruct the reversed path. 46 Path(const Path &P, const NodeIt &a, const NodeIt &b); 47 /// Subpath defined by two edges. Contains edges in [a,b) 48 /// It is an error if the two edges are not in order! 49 Path(const Path &P, const EdgeIt &a, const EdgeIt &b); 46 50 47 51 size_t length() const { return edges.size(); } … … 71 75 72 76 bool isForward(const EdgeIt &e) const { return e.forw; } 77 78 /// index of a node on the path. Returns length+2 for the invalid NodeIt 79 int index(const NodeIt &n) const { return n.idx; } 80 /// index of an edge on the path. Returns length+1 for the invalid EdgeIt 81 int index(const EdgeIt &e) const { return e.it  edges.begin(); } 73 82 74 83 EdgeIt& next(EdgeIt &e) const; … … 123 132 friend class EdgeIt; 124 133 125 int idx;134 size_t idx; 126 135 bool tail; // Is this node the tail of the edge with same idx? 127 136 … … 302 311 n.idx = e.itedges.begin(); 303 312 n.tail = e.forw; 313 return n; 304 314 } 305 315 … … 378 388 } 379 389 390 // Reszut konstruktorok: 391 392 393 template<typename Gr> 394 Path<Gr>::Path(const Path &P, const EdgeIt &a, const EdgeIt &b) : 395 G(P.G), edges(a.it, b.it) // WARNING: if b.it < a.it this will blow up! 396 { 397 if( G.valid(P._first) && a.it < P.edges.end() ) { 398 _first = ( a.forw ? G.tail(*a.it) : G.head(*a.it) ); 399 if( b.it < P.edges.end() ) { 400 _last = ( b.forw ? G.tail(*b.it) : G.head(*b.it) ); 401 } 402 else { 403 _last = P._last; 404 } 405 } 406 } 407 408 409 template<typename Gr> 410 Path<Gr>::Path(const Path &P, const NodeIt &a, const NodeIt &b) : 411 G(P.G) 412 { 413 if( !P.valid(a)  !P.valid(b) ) 414 return; 415 416 int ai = a.idx, bi = b.idx; 417 if( bi<ai ) 418 swap(ai,bi); 419 420 edges.resize(biai); 421 copy(P.edges.begin()+ai, P.edges.begin()+bi, edges.begin()); 422 423 _first = P.graphNode(a); 424 _last = P.graphNode(b); 425 } 426 380 427 381 428 } // namespace hugo
Note: See TracChangeset
for help on using the changeset viewer.