- int nb_time_steps = 4;
- int nb_locations = 5;
- // Add the source and sink
- int nb_vertices = nb_time_steps * nb_locations + 2;
- int nb_edges = nb_locations + (nb_time_steps - 1) * nb_locations * nb_locations + nb_locations;
- int source = 0;
- int sink = nb_locations - 1;
- scalar_t *es = new scalar_t[nb_edges];
- int *ea = new int[nb_edges];
- int *eb = new int[nb_edges];
-
- delete[] es;
- delete[] ea;
- delete[] eb;
+
+ if(argc < 2) {
+ cerr << argv[0] << " <graph file>" << endl;
+ exit(EXIT_FAILURE);
+ }
+
+ ifstream file(argv[1]);
+
+ int nb_edges, nb_vertices;
+ int source, sink;
+
+ if(file.good()) {
+ file >> nb_vertices >> nb_edges;
+ file >> source >> sink;
+
+ cout << "nb_edges = " << nb_edges << endl;
+ cout << "nb_vertices = " << nb_vertices << endl;
+ cout << "source = " << source << endl;
+ cout << "sink = " << sink << endl;
+
+ scalar_t *el = new scalar_t[nb_edges];
+ int *ea = new int[nb_edges];
+ int *eb = new int[nb_edges];
+ int *edge_occupation = new int[nb_edges];
+
+ for(int e = 0; e < nb_edges; e++) {
+ file >> ea[e] >> eb[e] >> el[e];
+#ifdef VERBOSE
+ cout << ea[e] << " -> " << eb[e] << " [" << el[e] << "]" << endl;
+#endif
+ }
+
+ find_best_paths(nb_vertices, nb_edges, el, ea, eb, source, sink,
+ edge_occupation);
+
+ for(int e = 0; e < nb_edges; e++) {
+ if(edge_occupation[e]) {
+ cout << ea[e] << " " << eb[e] << endl;
+ }
+ }
+
+ delete[] edge_occupation;
+ delete[] el;
+ delete[] ea;
+ delete[] eb;
+
+ } else {
+
+ cerr << "Can not open " << argv[1] << endl;
+ exit(EXIT_FAILURE);
+
+ }
+
+ exit(EXIT_SUCCESS);