projects
/
mtp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8a3940e
)
Cosmetics.
author
Francois Fleuret
<francois@fleuret.org>
Thu, 20 Dec 2012 08:40:39 +0000
(09:40 +0100)
committer
Francois Fleuret
<francois@fleuret.org>
Thu, 20 Dec 2012 08:40:39 +0000
(09:40 +0100)
mtp_graph.cc
patch
|
blob
|
history
diff --git
a/mtp_graph.cc
b/mtp_graph.cc
index
ea8f91b
..
5a7da77
100644
(file)
--- a/
mtp_graph.cc
+++ b/
mtp_graph.cc
@@
-202,44
+202,44
@@
int MTPGraph::compute_dp_ranks() {
// rank of a node is the iteration at which is it removed, and we
// set the distance_from_source fields to this value.
// rank of a node is the iteration at which is it removed, and we
// set the distance_from_source fields to this value.
- Vertex **
active
= new Vertex *[_nb_vertices];
+ Vertex **
unreached
= new Vertex *[_nb_vertices];
- // All the nodes are
active
at first
+ // All the nodes are
unreached
at first
for(int k = 0; k < _nb_vertices; k++) {
_vertices[k].distance_from_source = 0;
for(int k = 0; k < _nb_vertices; k++) {
_vertices[k].distance_from_source = 0;
-
active
[k] = &_vertices[k];
+
unreached
[k] = &_vertices[k];
}
scalar_t rank = 1;
}
scalar_t rank = 1;
- int nb_
active = _nb_vertices, pred_nb_active
;
+ int nb_
unreached = _nb_vertices, pred_nb_unreached
;
do {
// We set the distance_from_source field of all the vertices with incoming
// edges to the current rank value
do {
// We set the distance_from_source field of all the vertices with incoming
// edges to the current rank value
- for(int f = 0; f < nb_
active
; f++) {
- v =
active
[f];
+ for(int f = 0; f < nb_
unreached
; f++) {
+ v =
unreached
[f];
for(e = v->leaving_edges; e; e = e->next_leaving_edge) {
e->terminal_vertex->distance_from_source = rank;
}
}
for(e = v->leaving_edges; e; e = e->next_leaving_edge) {
e->terminal_vertex->distance_from_source = rank;
}
}
- pred_nb_
active = nb_active
;
- nb_
active
= 0;
+ pred_nb_
unreached = nb_unreached
;
+ nb_
unreached
= 0;
// We keep all the vertices with incoming nodes
// We keep all the vertices with incoming nodes
- for(int f = 0; f < pred_nb_
active
; f++) {
- v =
active
[f];
+ for(int f = 0; f < pred_nb_
unreached
; f++) {
+ v =
unreached
[f];
if(v->distance_from_source == rank) {
if(v->distance_from_source == rank) {
-
active[nb_active
++] = v;
+
unreached[nb_unreached
++] = v;
}
}
rank++;
}
}
rank++;
- } while(nb_
active < pred_nb_active
);
+ } while(nb_
unreached < pred_nb_unreached
);
- delete[]
active
;
+ delete[]
unreached
;
- return nb_
active
== 0;
+ return nb_
unreached
== 0;
}
//////////////////////////////////////////////////////////////////////
}
//////////////////////////////////////////////////////////////////////
@@
-384,7
+384,7
@@
void MTPGraph::find_shortest_path() {
}
void MTPGraph::find_best_paths(scalar_t *lengths) {
}
void MTPGraph::find_best_paths(scalar_t *lengths) {
- scalar_t
total
_length;
+ scalar_t
shortest_path
_length;
Vertex *v;
Edge *e;
Vertex *v;
Edge *e;
@@
-408,7
+408,7
@@
void MTPGraph::find_best_paths(scalar_t *lengths) {
find_shortest_path();
find_shortest_path();
-
total
_length = 0.0;
+
shortest_path
_length = 0.0;
// Do we reach the sink?
if(_sink->pred_edge_toward_source) {
// Do we reach the sink?
if(_sink->pred_edge_toward_source) {
@@
-416,13
+416,13
@@
void MTPGraph::find_best_paths(scalar_t *lengths) {
// original edge lengths
v = _sink;
while(v->pred_edge_toward_source) {
// original edge lengths
v = _sink;
while(v->pred_edge_toward_source) {
-
total
_length += v->pred_edge_toward_source->length;
+
shortest_path
_length += v->pred_edge_toward_source->length;
v = v->pred_edge_toward_source->origin_vertex;
}
// If that length is negative
v = v->pred_edge_toward_source->origin_vertex;
}
// If that length is negative
- if(
total
_length < 0.0) {
+ if(
shortest_path
_length < 0.0) {
#ifdef VERBOSE
#ifdef VERBOSE
- cerr << __FILE__ << ": Found a path of length " <<
total
_length << endl;
+ cerr << __FILE__ << ": Found a path of length " <<
shortest_path
_length << endl;
#endif
// Invert all the edges along the best path
v = _sink;
#endif
// Invert all the edges along the best path
v = _sink;
@@
-437,7
+437,7
@@
void MTPGraph::find_best_paths(scalar_t *lengths) {
}
}
}
}
- } while(
total
_length < 0.0);
+ } while(
shortest_path
_length < 0.0);
// Put back the graph in its original state (i.e. invert edges which
// have been inverted in the process)
// Put back the graph in its original state (i.e. invert edges which
// have been inverted in the process)