projects
/
mtp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1bafc06
)
Cosmetics.
author
Francois Fleuret
<francois@fleuret.org>
Sat, 29 Dec 2012 23:52:00 +0000
(
00:52
+0100)
committer
Francois Fleuret
<francois@fleuret.org>
Sat, 29 Dec 2012 23:52:00 +0000
(
00:52
+0100)
mtp_graph.cc
patch
|
blob
|
history
diff --git
a/mtp_graph.cc
b/mtp_graph.cc
index
48de3ca
..
c17917e
100644
(file)
--- a/
mtp_graph.cc
+++ b/
mtp_graph.cc
@@
-133,17
+133,6
@@
void Vertex::increase_distance_in_heap(Vertex **heap, Vertex **heap_bottom) {
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
-static int compare_vertices_on_distance(const void *v1, const void *v2) {
- scalar_t delta =
- (*((Vertex **) v1))->distance_from_source -
- (*((Vertex **) v2))->distance_from_source;
- if(delta < 0) return -1;
- else if(delta > 0) return 1;
- else return 0;
-}
-
-//////////////////////////////////////////////////////////////////////
-
MTPGraph::MTPGraph(int nb_vertices, int nb_edges,
int *vertex_from, int *vertex_to,
int source, int sink) {
MTPGraph::MTPGraph(int nb_vertices, int nb_edges,
int *vertex_from, int *vertex_to,
int source, int sink) {
@@
-430,14
+419,23
@@
int MTPGraph::retrieve_one_path(Edge *e, Path *path) {
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
+static int compare_vertices_on_distance(const void *v1, const void *v2) {
+ scalar_t delta =
+ (*((Vertex **) v1))->distance_from_source -
+ (*((Vertex **) v2))->distance_from_source;
+ if(delta < 0) return -1;
+ else if(delta > 0) return 1;
+ else return 0;
+}
+
void MTPGraph::compute_dp_ordering() {
Vertex *v;
Edge *e;
void MTPGraph::compute_dp_ordering() {
Vertex *v;
Edge *e;
- int tv;
+ int
n
tv;
- // This
procedure computes for each node the longest link from the
- //
source, and abort if the graph is not a DAG, and order the node
- // i
n _dp_order according to that value
.
+ // This
method computes for each node the length of the longest link
+ //
from the source, and orders the node in _dp_order according to
+ // i
t. It aborts if the graph is not a DAG
.
int *nb_predecessors = new int[_nb_vertices];
int *nb_predecessors = new int[_nb_vertices];
@@
-450,8
+448,8
@@
void MTPGraph::compute_dp_ordering() {
for(int k = 0; k < _nb_vertices; k++) {
v = &_vertices[k];
for(e = v->leaving_edge_list_root; e; e = e->next_leaving_edge) {
for(int k = 0; k < _nb_vertices; k++) {
v = &_vertices[k];
for(e = v->leaving_edge_list_root; e; e = e->next_leaving_edge) {
- tv = int(e->terminal_vertex - _vertices);
- nb_predecessors[tv]++;
+
n
tv = int(e->terminal_vertex - _vertices);
+ nb_predecessors[
n
tv]++;
}
}
}
}
@@
-468,10
+466,10
@@
void MTPGraph::compute_dp_ordering() {
v = *(already_processed++);
v->distance_from_source = rank;
for(e = v->leaving_edge_list_root; e; e = e->next_leaving_edge) {
v = *(already_processed++);
v->distance_from_source = rank;
for(e = v->leaving_edge_list_root; e; e = e->next_leaving_edge) {
- tv = int(e->terminal_vertex - _vertices);
- nb_predecessors[tv]--;
- ASSERT(nb_predecessors[tv] >= 0);
- if(nb_predecessors[tv] == 0) {
+
n
tv = int(e->terminal_vertex - _vertices);
+ nb_predecessors[
n
tv]--;
+ ASSERT(nb_predecessors[
n
tv] >= 0);
+ if(nb_predecessors[
n
tv] == 0) {
*(new_front++) = e->terminal_vertex;
}
}
*(new_front++) = e->terminal_vertex;
}
}