//////////////////////////////////////////////////////////////////////
-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) {
//////////////////////////////////////////////////////////////////////
+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;
- int tv;
+ int ntv;
- // 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
- // in _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
+ // it. It aborts if the graph is not a DAG.
int *nb_predecessors = new int[_nb_vertices];
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]++;
+ ntv = int(e->terminal_vertex - _vertices);
+ nb_predecessors[ntv]++;
}
}
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) {
+ ntv = int(e->terminal_vertex - _vertices);
+ nb_predecessors[ntv]--;
+ ASSERT(nb_predecessors[ntv] >= 0);
+ if(nb_predecessors[ntv] == 0) {
*(new_front++) = e->terminal_vertex;
}
}