0
2
0
60
60
13
12
... | ... |
@@ -44,12 +44,13 @@ |
44 | 44 |
/// |
45 | 45 |
/// In a sense, the path can be treated as a list of arcs. The |
46 |
/// lemon path type stores just this list. As a consequence it |
|
47 |
/// cannot enumerate the nodes in the path and the zero length paths |
|
48 |
/// |
|
46 |
/// lemon path type stores just this list. As a consequence, it |
|
47 |
/// cannot enumerate the nodes of the path and the source node of |
|
48 |
/// a zero length path is undefined. |
|
49 | 49 |
/// |
50 | 50 |
/// This implementation is a back and front insertable and erasable |
51 | 51 |
/// path type. It can be indexed in O(1) time. The front and back |
52 |
/// insertion and erasure is amortized O(1) time. The |
|
53 |
/// impelementation is based on two opposite organized vectors. |
|
52 |
/// insertion and erase is done in O(1) (amortized) time. The |
|
53 |
/// implementation uses two vectors for storing the front and back |
|
54 |
/// insertions. |
|
54 | 55 |
template <typename _Digraph> |
55 | 56 |
class Path { |
... | ... |
@@ -66,6 +67,6 @@ |
66 | 67 |
/// \brief Template copy constructor |
67 | 68 |
/// |
68 |
/// This path can be initialized with any other path type. It just |
|
69 |
/// makes a copy of the given path. |
|
69 |
/// This constuctor initializes the path from any other path type. |
|
70 |
/// It simply makes a copy of the given path. |
|
70 | 71 |
template <typename CPath> |
71 | 72 |
Path(const CPath& cpath) { |
... | ... |
@@ -75,6 +76,5 @@ |
75 | 76 |
/// \brief Template copy assignment |
76 | 77 |
/// |
77 |
/// This path can be initialized with any other path type. It just |
|
78 |
/// makes a copy of the given path. |
|
78 |
/// This operator makes a copy of a path of any other type. |
|
79 | 79 |
template <typename CPath> |
80 | 80 |
Path& operator=(const CPath& cpath) { |
... | ... |
@@ -93,5 +93,5 @@ |
93 | 93 |
/// \brief Invalid constructor |
94 | 94 |
ArcIt(Invalid) : path(0), idx(-1) {} |
95 |
/// \brief Initializate the |
|
95 |
/// \brief Initializate the iterator to the first arc of path |
|
96 | 96 |
ArcIt(const Path &_path) |
97 | 97 |
: path(&_path), idx(_path.empty() ? -1 : 0) {} |
... | ... |
@@ -130,11 +130,11 @@ |
130 | 130 |
/// \brief Length of the path. |
131 | 131 |
int length() const { return head.size() + tail.size(); } |
132 |
/// \brief |
|
132 |
/// \brief Return whether the path is empty. |
|
133 | 133 |
bool empty() const { return head.empty() && tail.empty(); } |
134 | 134 |
|
135 |
/// \brief |
|
135 |
/// \brief Reset the path to an empty one. |
|
136 | 136 |
void clear() { head.clear(); tail.clear(); } |
137 | 137 |
|
138 |
/// \brief |
|
138 |
/// \brief The nth arc. |
|
139 | 139 |
/// |
140 | 140 |
/// \pre n is in the [0..length() - 1] range |
... | ... |
@@ -144,5 +144,5 @@ |
144 | 144 |
} |
145 | 145 |
|
146 |
/// \brief |
|
146 |
/// \brief Initialize arc iterator to point to the nth arc |
|
147 | 147 |
/// |
148 | 148 |
/// \pre n is in the [0..length() - 1] range |
... | ... |
@@ -151,5 +151,5 @@ |
151 | 151 |
} |
152 | 152 |
|
153 |
/// \brief |
|
153 |
/// \brief The first arc of the path |
|
154 | 154 |
const Arc& front() const { |
155 | 155 |
return head.empty() ? tail.front() : head.back(); |
... | ... |
@@ -176,5 +176,5 @@ |
176 | 176 |
} |
177 | 177 |
|
178 |
/// \brief |
|
178 |
/// \brief The last arc of the path |
|
179 | 179 |
const Arc& back() const { |
180 | 180 |
return tail.empty() ? head.front() : tail.back(); |
... | ... |
@@ -200,6 +200,4 @@ |
200 | 200 |
} |
201 | 201 |
|
202 |
|
|
203 |
|
|
204 | 202 |
typedef True BuildTag; |
205 | 203 |
|
... | ... |
@@ -324,11 +322,11 @@ |
324 | 322 |
/// \brief Length of the path. |
325 | 323 |
int length() const { return data.size(); } |
326 |
/// \brief |
|
324 |
/// \brief Return true if the path is empty. |
|
327 | 325 |
bool empty() const { return data.empty(); } |
328 | 326 |
|
329 |
/// \brief |
|
327 |
/// \brief Reset the path to an empty one. |
|
330 | 328 |
void clear() { data.clear(); } |
331 | 329 |
|
332 |
/// \brief |
|
330 |
/// \brief The nth arc. |
|
333 | 331 |
/// |
334 | 332 |
/// \pre n is in the [0..length() - 1] range |
... | ... |
@@ -342,10 +340,10 @@ |
342 | 340 |
} |
343 | 341 |
|
344 |
/// \brief |
|
342 |
/// \brief The first arc of the path. |
|
345 | 343 |
const Arc& front() const { |
346 | 344 |
return data.front(); |
347 | 345 |
} |
348 | 346 |
|
349 |
/// \brief |
|
347 |
/// \brief The last arc of the path. |
|
350 | 348 |
const Arc& back() const { |
351 | 349 |
return data.back(); |
... | ... |
@@ -507,7 +505,7 @@ |
507 | 505 |
}; |
508 | 506 |
|
509 |
/// \brief |
|
507 |
/// \brief The nth arc. |
|
510 | 508 |
/// |
511 |
/// |
|
509 |
/// This function looks for the nth arc in O(n) time. |
|
512 | 510 |
/// \pre n is in the [0..length() - 1] range |
513 | 511 |
const Arc& nth(int n) const { |
... | ... |
@@ -539,8 +537,8 @@ |
539 | 537 |
} |
540 | 538 |
|
541 |
/// \brief |
|
539 |
/// \brief Return true if the path is empty. |
|
542 | 540 |
bool empty() const { return first == 0; } |
543 | 541 |
|
544 |
/// \brief |
|
542 |
/// \brief Reset the path to an empty one. |
|
545 | 543 |
void clear() { |
546 | 544 |
while (first != 0) { |
... | ... |
@@ -552,5 +550,5 @@ |
552 | 550 |
} |
553 | 551 |
|
554 |
/// \brief |
|
552 |
/// \brief The first arc of the path |
|
555 | 553 |
const Arc& front() const { |
556 | 554 |
return first->arc; |
... | ... |
@@ -585,5 +583,5 @@ |
585 | 583 |
} |
586 | 584 |
|
587 |
/// \brief |
|
585 |
/// \brief The last arc of the path. |
|
588 | 586 |
const Arc& back() const { |
589 | 587 |
return last->arc; |
... | ... |
@@ -618,7 +616,7 @@ |
618 | 616 |
} |
619 | 617 |
|
620 |
/// \brief |
|
618 |
/// \brief Splice a path to the back of the current path. |
|
621 | 619 |
/// |
622 |
/// It splices |
|
620 |
/// It splices \c tpath to the back of the current path and \c |
|
623 | 621 |
/// tpath becomes empty. The time complexity of this function is |
624 | 622 |
/// O(1). |
... | ... |
@@ -637,7 +635,7 @@ |
637 | 635 |
} |
638 | 636 |
|
639 |
/// \brief |
|
637 |
/// \brief Splice a path to the front of the current path. |
|
640 | 638 |
/// |
641 |
/// It splices |
|
639 |
/// It splices \c tpath before the current path and \c tpath |
|
642 | 640 |
/// becomes empty. The time complexity of this function |
643 | 641 |
/// is O(1). |
... | ... |
@@ -656,10 +654,10 @@ |
656 | 654 |
} |
657 | 655 |
|
658 |
/// \brief |
|
656 |
/// \brief Splice a path into the current path. |
|
659 | 657 |
/// |
660 | 658 |
/// It splices the \c tpath into the current path before the |
661 | 659 |
/// position of \c it iterator and \c tpath becomes empty. The |
662 |
/// time complexity of this function is O(1). If the \c it is \c |
|
663 |
/// INVALID then it will splice behind the current path. |
|
660 |
/// time complexity of this function is O(1). If the \c it is |
|
661 |
/// \c INVALID then it will splice behind the current path. |
|
664 | 662 |
void splice(ArcIt it, ListPath& tpath) { |
665 | 663 |
if (it.node) { |
... | ... |
@@ -689,13 +687,13 @@ |
689 | 687 |
} |
690 | 688 |
|
691 |
/// \brief |
|
689 |
/// \brief Split the current path. |
|
692 | 690 |
/// |
693 |
/// It splits the current path into two parts. The part before \c |
|
694 |
/// it iterator will remain in the current path and the part from |
|
695 |
/// the it will put into the \c tpath. If the \c tpath had arcs |
|
696 |
/// before the operation they will be removed first. The time |
|
697 |
/// complexity of this function is O(1) plus the clearing of \c |
|
698 |
/// tpath. If the \c it is \c INVALID then it just clears \c |
|
699 |
/// |
|
691 |
/// It splits the current path into two parts. The part before |
|
692 |
/// the iterator \c it will remain in the current path and the part |
|
693 |
/// starting with |
|
694 |
/// \c it will put into \c tpath. If \c tpath have arcs |
|
695 |
/// before the operation they are removed first. The time |
|
696 |
/// complexity of this function is O(1) plus the the time of emtying |
|
697 |
/// \c tpath. If \c it is \c INVALID then it just clears \c tpath |
|
700 | 698 |
void split(ArcIt it, ListPath& tpath) { |
701 | 699 |
tpath.clear(); |
... | ... |
@@ -739,11 +737,14 @@ |
739 | 737 |
/// In a sense, the path can be treated as a list of arcs. The |
740 | 738 |
/// lemon path type stores just this list. As a consequence it |
741 |
/// cannot enumerate the nodes in the path and the zero length paths |
|
742 |
/// cannot store the source. |
|
739 |
/// cannot enumerate the nodes in the path and the source node of |
|
740 |
/// a zero length path is undefined. |
|
743 | 741 |
/// |
744 |
/// This implementation is completly static, so it cannot be |
|
745 |
/// modified exclude the assign an other path. It is intented to be |
|
746 |
/// used when you want to store a large number of paths because it is |
|
747 |
/// the most memory efficient path type in the lemon. |
|
742 |
/// This implementation is completly static, i.e. it can be copy constucted |
|
743 |
/// or copy assigned from another path, but otherwise it cannot be |
|
744 |
/// modified. |
|
745 |
/// |
|
746 |
/// Being the the most memory efficient path type in LEMON, |
|
747 |
/// it is intented to be |
|
748 |
/// used when you want to store a large number of paths. |
|
748 | 749 |
template <typename _Digraph> |
749 | 750 |
class StaticPath { |
... | ... |
@@ -760,6 +761,5 @@ |
760 | 761 |
/// \brief Template copy constructor |
761 | 762 |
/// |
762 |
/// This path can be initialized with any other path type. It just |
|
763 |
/// makes a copy of the given path. |
|
763 |
/// This path can be initialized from any other path type. |
|
764 | 764 |
template <typename CPath> |
765 | 765 |
StaticPath(const CPath& cpath) : arcs(0) { |
... | ... |
@@ -776,5 +776,5 @@ |
776 | 776 |
/// \brief Template copy assignment |
777 | 777 |
/// |
778 |
/// This path can be |
|
778 |
/// This path can be made equal to any other path type. It simply |
|
779 | 779 |
/// makes a copy of the given path. |
780 | 780 |
template <typename CPath> |
... | ... |
@@ -832,5 +832,5 @@ |
832 | 832 |
}; |
833 | 833 |
|
834 |
/// \brief |
|
834 |
/// \brief The nth arc. |
|
835 | 835 |
/// |
836 | 836 |
/// \pre n is in the [0..length() - 1] range |
... | ... |
@@ -839,16 +839,16 @@ |
839 | 839 |
} |
840 | 840 |
|
841 |
/// \brief |
|
841 |
/// \brief The arc iterator pointing to the nth arc. |
|
842 | 842 |
ArcIt nthIt(int n) const { |
843 | 843 |
return ArcIt(*this, n); |
844 | 844 |
} |
845 | 845 |
|
846 |
/// \brief |
|
846 |
/// \brief The length of the path. |
|
847 | 847 |
int length() const { return len; } |
848 | 848 |
|
849 |
/// \brief |
|
849 |
/// \brief Return true when the path is empty. |
|
850 | 850 |
int empty() const { return len == 0; } |
851 | 851 |
|
852 |
/// \break Erase all |
|
852 |
/// \break Erase all arcs in the digraph. |
|
853 | 853 |
void clear() { |
854 | 854 |
len = 0; |
... | ... |
@@ -857,10 +857,10 @@ |
857 | 857 |
} |
858 | 858 |
|
859 |
/// \brief |
|
859 |
/// \brief The first arc of the path. |
|
860 | 860 |
const Arc& front() const { |
861 | 861 |
return arcs[0]; |
862 | 862 |
} |
863 | 863 |
|
864 |
/// \brief |
|
864 |
/// \brief The last arc of the path. |
|
865 | 865 |
const Arc& back() const { |
866 | 866 |
return arcs[len - 1]; |
... | ... |
@@ -91,7 +91,7 @@ |
91 | 91 |
|
92 | 92 |
|
93 |
/// \brief Make |
|
93 |
/// \brief Make a copy of a path. |
|
94 | 94 |
/// |
95 |
/// |
|
95 |
/// This function makes a copy of a path. |
|
96 | 96 |
template <typename Target, typename Source> |
97 | 97 |
void copyPath(Target& target, const Source& source) { |
... | ... |
@@ -100,7 +100,8 @@ |
100 | 100 |
} |
101 | 101 |
|
102 |
/// \brief |
|
102 |
/// \brief Check the consistency of a path. |
|
103 | 103 |
/// |
104 |
/// |
|
104 |
/// This function checks that the target of each arc is the same |
|
105 |
/// as the source of the next one. |
|
105 | 106 |
/// |
106 | 107 |
template <typename Digraph, typename Path> |
... | ... |
@@ -118,7 +119,7 @@ |
118 | 119 |
} |
119 | 120 |
|
120 |
/// \brief |
|
121 |
/// \brief The source of a path |
|
121 | 122 |
/// |
122 |
/// |
|
123 |
/// This function returns the source of the given path. |
|
123 | 124 |
template <typename Digraph, typename Path> |
124 | 125 |
typename Digraph::Node pathSource(const Digraph& digraph, const Path& path) { |
... | ... |
@@ -126,7 +127,7 @@ |
126 | 127 |
} |
127 | 128 |
|
128 |
/// \brief |
|
129 |
/// \brief The target of a path |
|
129 | 130 |
/// |
130 |
/// |
|
131 |
/// This function returns the target of the given path. |
|
131 | 132 |
template <typename Digraph, typename Path> |
132 | 133 |
typename Digraph::Node pathTarget(const Digraph& digraph, const Path& path) { |
... | ... |
@@ -134,13 +135,13 @@ |
134 | 135 |
} |
135 | 136 |
|
136 |
/// \brief Class which helps to iterate the nodes of a path |
|
137 |
/// \brief Class which helps to iterate through the nodes of a path |
|
137 | 138 |
/// |
138 | 139 |
/// In a sense, the path can be treated as a list of arcs. The |
139 |
/// lemon path type stores |
|
140 |
/// lemon path type stores only this list. As a consequence, it |
|
140 | 141 |
/// cannot enumerate the nodes in the path and the zero length paths |
141 |
/// cannot |
|
142 |
/// cannot have a source node. |
|
142 | 143 |
/// |
143 | 144 |
/// This class implements the node iterator of a path structure. To |
144 |
/// provide this feature, the underlying digraph should be |
|
145 |
/// provide this feature, the underlying digraph should be passed to |
|
145 | 146 |
/// the constructor of the iterator. |
146 | 147 |
template <typename Path> |
0 comments (0 inline)