... | ... |
@@ -28,49 +28,49 @@ |
28 | 28 |
class PredMapPath { |
29 | 29 |
public: |
30 | 30 |
typedef True RevPathTag; |
31 | 31 |
|
32 | 32 |
typedef _Digraph Digraph; |
33 | 33 |
typedef typename Digraph::Arc Arc; |
34 | 34 |
typedef _PredMap PredMap; |
35 | 35 |
|
36 | 36 |
PredMapPath(const Digraph& _digraph, const PredMap& _predMap, |
37 | 37 |
typename Digraph::Node _target) |
38 | 38 |
: digraph(_digraph), predMap(_predMap), target(_target) {} |
39 | 39 |
|
40 | 40 |
int length() const { |
41 | 41 |
int len = 0; |
42 | 42 |
typename Digraph::Node node = target; |
43 | 43 |
typename Digraph::Arc arc; |
44 | 44 |
while ((arc = predMap[node]) != INVALID) { |
45 | 45 |
node = digraph.source(arc); |
46 | 46 |
++len; |
47 | 47 |
} |
48 | 48 |
return len; |
49 | 49 |
} |
50 | 50 |
|
51 | 51 |
bool empty() const { |
52 |
return predMap[target] |
|
52 |
return predMap[target] == INVALID; |
|
53 | 53 |
} |
54 | 54 |
|
55 | 55 |
class RevArcIt { |
56 | 56 |
public: |
57 | 57 |
RevArcIt() {} |
58 | 58 |
RevArcIt(Invalid) : path(0), current(INVALID) {} |
59 | 59 |
RevArcIt(const PredMapPath& _path) |
60 | 60 |
: path(&_path), current(_path.target) { |
61 | 61 |
if (path->predMap[current] == INVALID) current = INVALID; |
62 | 62 |
} |
63 | 63 |
|
64 | 64 |
operator const typename Digraph::Arc() const { |
65 | 65 |
return path->predMap[current]; |
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
RevArcIt& operator++() { |
69 | 69 |
current = path->digraph.source(path->predMap[current]); |
70 | 70 |
if (path->predMap[current] == INVALID) current = INVALID; |
71 | 71 |
return *this; |
72 | 72 |
} |
73 | 73 |
|
74 | 74 |
bool operator==(const RevArcIt& e) const { |
75 | 75 |
return current == e.current; |
76 | 76 |
} |
... | ... |
@@ -102,49 +102,49 @@ |
102 | 102 |
|
103 | 103 |
typedef _Digraph Digraph; |
104 | 104 |
typedef typename Digraph::Arc Arc; |
105 | 105 |
typedef _PredMatrixMap PredMatrixMap; |
106 | 106 |
|
107 | 107 |
PredMatrixMapPath(const Digraph& _digraph, |
108 | 108 |
const PredMatrixMap& _predMatrixMap, |
109 | 109 |
typename Digraph::Node _source, |
110 | 110 |
typename Digraph::Node _target) |
111 | 111 |
: digraph(_digraph), predMatrixMap(_predMatrixMap), |
112 | 112 |
source(_source), target(_target) {} |
113 | 113 |
|
114 | 114 |
int length() const { |
115 | 115 |
int len = 0; |
116 | 116 |
typename Digraph::Node node = target; |
117 | 117 |
typename Digraph::Arc arc; |
118 | 118 |
while ((arc = predMatrixMap(source, node)) != INVALID) { |
119 | 119 |
node = digraph.source(arc); |
120 | 120 |
++len; |
121 | 121 |
} |
122 | 122 |
return len; |
123 | 123 |
} |
124 | 124 |
|
125 | 125 |
bool empty() const { |
126 |
return source |
|
126 |
return predMatrixMap(source, target) == INVALID; |
|
127 | 127 |
} |
128 | 128 |
|
129 | 129 |
class RevArcIt { |
130 | 130 |
public: |
131 | 131 |
RevArcIt() {} |
132 | 132 |
RevArcIt(Invalid) : path(0), current(INVALID) {} |
133 | 133 |
RevArcIt(const PredMatrixMapPath& _path) |
134 | 134 |
: path(&_path), current(_path.target) { |
135 | 135 |
if (path->predMatrixMap(path->source, current) == INVALID) |
136 | 136 |
current = INVALID; |
137 | 137 |
} |
138 | 138 |
|
139 | 139 |
operator const typename Digraph::Arc() const { |
140 | 140 |
return path->predMatrixMap(path->source, current); |
141 | 141 |
} |
142 | 142 |
|
143 | 143 |
RevArcIt& operator++() { |
144 | 144 |
current = |
145 | 145 |
path->digraph.source(path->predMatrixMap(path->source, current)); |
146 | 146 |
if (path->predMatrixMap(path->source, current) == INVALID) |
147 | 147 |
current = INVALID; |
148 | 148 |
return *this; |
149 | 149 |
} |
150 | 150 |
|
0 comments (0 inline)