projects
/
mtp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
82614b1
)
Cosmetics + fixed the buggy bug-check in retrieve_one_path.
author
Francois Fleuret
<francois@fleuret.org>
Sat, 8 Sep 2012 14:16:34 +0000
(16:16 +0200)
committer
Francois Fleuret
<francois@fleuret.org>
Sat, 8 Sep 2012 14:16:34 +0000
(16:16 +0200)
mtp_graph.cc
patch
|
blob
|
history
diff --git
a/mtp_graph.cc
b/mtp_graph.cc
index
ecbbab5
..
c456601
100644
(file)
--- a/
mtp_graph.cc
+++ b/
mtp_graph.cc
@@
-229,8
+229,8
@@
int MTPGraph::is_dag() {
int front_size = _nb_vertices, pred_front_size;
do {
int front_size = _nb_vertices, pred_front_size;
do {
- // We set the
iteration field of all vertex with incoming edges to
- // the current iteration value
+ // We set the
last_change field of all the vertices with incoming
+ //
edges to
the current iteration value
for(int f = 0; f < front_size; f++) {
v = _front[f];
for(e = v->leaving_edges; e; e = e->next_leaving_edge) {
for(int f = 0; f < front_size; f++) {
v = _front[f];
for(e = v->leaving_edges; e; e = e->next_leaving_edge) {
@@
-241,7
+241,7
@@
int MTPGraph::is_dag() {
pred_front_size = front_size;
front_size = 0;
pred_front_size = front_size;
front_size = 0;
- // We
remove all the vertices without incoming edge
+ // We
keep all the vertices with incoming nodes
for(int f = 0; f < pred_front_size; f++) {
v = _front[f];
if(v->last_change == iteration) {
for(int f = 0; f < pred_front_size; f++) {
v = _front[f];
if(v->last_change == iteration) {
@@
-256,7
+256,7
@@
int MTPGraph::is_dag() {
}
// This method does not change the edge occupation. It only set
}
// This method does not change the edge occupation. It only set
-// properly
for every vertex
the fields distance_from_source and
+// properly
, for every vertex,
the fields distance_from_source and
// pred_edge_toward_source.
void MTPGraph::find_shortest_path() {
// pred_edge_toward_source.
void MTPGraph::find_shortest_path() {
@@
-370,7
+370,7
@@
void MTPGraph::find_best_paths(scalar_t *lengths) {
// Put back the graph in its original state (i.e. invert edges which
// have been inverted in the process)
for(int k = 0; k < _nb_edges; k++) {
// Put back the graph in its original state (i.e. invert edges which
// have been inverted in the process)
for(int k = 0; k < _nb_edges; k++) {
-
Edge *
e = _edges + k;
+ e = _edges + k;
if(e->occupied) { e->invert(); }
}
}
if(e->occupied) { e->invert(); }
}
}
@@
-392,15
+392,19
@@
int MTPGraph::retrieve_one_path(Edge *e, Path *path) {
int nb_choices = 0;
for(f = e->terminal_vertex->leaving_edges; f; f = f->next_leaving_edge) {
if(f->occupied) { nb_choices++; next = f; }
int nb_choices = 0;
for(f = e->terminal_vertex->leaving_edges; f; f = f->next_leaving_edge) {
if(f->occupied) { nb_choices++; next = f; }
- if(nb_choices == 0) {
- cerr << "retrieve_one_path: Non-sink end point." << endl;
- abort();
- }
- if(nb_choices > 1) {
- cerr << "retrieve_one_path: Non node-disjoint paths." << endl;
- abort();
- }
}
}
+
+#ifdef DEBUG
+ if(nb_choices == 0) {
+ cerr << "retrieve_one_path: Non-sink end point." << endl;
+ abort();
+ }
+ if(nb_choices > 1) {
+ cerr << "retrieve_one_path: Non node-disjoint paths." << endl;
+ abort();
+ }
+#endif
+
e = next;
}
e = next;
}