... | ... |
@@ -77,17 +77,23 @@ |
77 | 77 |
/// the tour will start from the first node. |
78 | 78 |
DiEulerIt(const GR &gr, typename GR::Node start = INVALID) |
79 | 79 |
: g(gr), nedge(g) |
80 | 80 |
{ |
81 |
if(start==INVALID) |
|
81 |
if (start==INVALID) { |
|
82 |
NodeIt n(g); |
|
83 |
while (n!=INVALID && OutArcIt(g,n)==INVALID) ++n; |
|
84 |
start=n; |
|
85 |
} |
|
86 |
if (start!=INVALID) { |
|
82 | 87 |
for(NodeIt n(g);n!=INVALID;++n) nedge[n]=OutArcIt(g,n); |
83 | 88 |
while(nedge[start]!=INVALID) { |
84 | 89 |
euler.push_back(nedge[start]); |
85 | 90 |
Node next=g.target(nedge[start]); |
86 | 91 |
++nedge[start]; |
87 | 92 |
start=next; |
88 | 93 |
} |
89 | 94 |
} |
95 |
} |
|
90 | 96 |
|
91 | 97 |
///Arc Conversion |
92 | 98 |
operator Arc() { return euler.empty()?INVALID:euler.front(); } |
93 | 99 |
bool operator==(Invalid) { return euler.empty(); } |
... | ... |
@@ -170,9 +176,14 @@ |
170 | 176 |
/// the tour will start from the first node. |
171 | 177 |
EulerIt(const GR &gr, typename GR::Node start = INVALID) |
172 | 178 |
: g(gr), nedge(g), visited(g, false) |
173 | 179 |
{ |
174 |
if(start==INVALID) |
|
180 |
if (start==INVALID) { |
|
181 |
NodeIt n(g); |
|
182 |
while (n!=INVALID && OutArcIt(g,n)==INVALID) ++n; |
|
183 |
start=n; |
|
184 |
} |
|
185 |
if (start!=INVALID) { |
|
175 | 186 |
for(NodeIt n(g);n!=INVALID;++n) nedge[n]=OutArcIt(g,n); |
176 | 187 |
while(nedge[start]!=INVALID) { |
177 | 188 |
euler.push_back(nedge[start]); |
178 | 189 |
visited[nedge[start]]=true; |
... | ... |
@@ -181,8 +192,9 @@ |
181 | 192 |
start=next; |
182 | 193 |
while(nedge[start]!=INVALID && visited[nedge[start]]) ++nedge[start]; |
183 | 194 |
} |
184 | 195 |
} |
196 |
} |
|
185 | 197 |
|
186 | 198 |
///Arc Conversion |
187 | 199 |
operator Arc() const { return euler.empty()?INVALID:euler.front(); } |
188 | 200 |
///Arc Conversion |
0 comments (0 inline)