// END_IP_HEADER //
///////////////////////////////////////////////////////////////////////////
-#define VERBOSE
+// #define VERBOSE
#include <iostream>
#include <fstream>
class Vertex {
public:
+ int id;
// These are the leaving edges
Edge *first_edge;
scalar_t distance;
void find_shortest_path();
void find_best_paths();
void print();
+ void print_occupied_edges();
};
void Graph::print() {
for(int n = 0; n < nb_vertices; n++) {
- cout << "VERTEX [" << n << "] ";
for(Edge *e = vertices[n].first_edge; e; e = e->next) {
- cout << " " << e->length;
+ cout << n << " -> " << e->terminal_vertex->id << " " << e->length << endl;
+ }
+ }
+}
+
+void Graph::print_occupied_edges() {
+ for(int n = 0; n < nb_vertices; n++) {
+ for(Edge *e = vertices[n].first_edge; e; e = e->next) {
+ if(e->occupied) {
+ int a = n, b = e->terminal_vertex->id;
+ if(a > b) { int c = a; a = b; b = c; }
+ cout << a << " " << b << endl;
+ }
}
- cout << endl;
}
}
source = &vertices[src];
sink = &vertices[snk];
+ for(int v = 0; v < nb_vertices; v++) {
+ vertices[v].id = v;
+ }
+
for(int e = 0; e < nb_edges; e++) {
vertices[from[e]].add_edge(&edge_heap[e]);
edge_heap[e].occupied = 0;
tmp_front_size = new_front_size;
new_front_size = front_size;
front_size = tmp_front_size;
- cout << "front_size = " << front_size << endl;
} while(front_size > 0);
delete[] front;
initialize_fixed_lengths();
do {
+#ifdef VERBOSE
print();
+#endif
total_length = 0.0;
find_shortest_path();
e->fixed_length = - e->fixed_length;
v->pred_vertex->del_edge(e);
v->add_edge(e);
- cout << "INVERT!" << endl;
}
}
}
Graph graph(nb_vertices, nb_edges, ea, eb, el, source, sink);
graph.find_best_paths();
+ graph.print_occupied_edges();
delete[] el;
delete[] ea;