-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;
- }
- }
- }
-}
-
-void Graph::dot_print() {
- cout << "digraph {" << endl;
- cout << " node[shape=circle];" << endl;
- for(int n = 0; n < nb_vertices; n++) {
- for(Edge *e = vertices[n].first_edge; e; e = e->next) {
- int a = n, b = e->terminal_vertex->id;
- if(e->occupied) {
- int c = a; a = b; b = c;
- cout << " " << a << " -> " << b << " [style=bold,color=black,label=\"" << -e->length << "\"];" << endl;
- } else {
- cout << " " << a << " -> " << b << " [color=gray,label=\"" << e->length << "\"];" << endl;
- }
- }
- }
- cout << "}" << endl;
-}
-
-Graph::Graph(int nb_vrt, int nb_edges,
- int *from, int *to, scalar_t *lengths,
- int src, int snk) {
- nb_vertices = nb_vrt;
-
- edge_heap = new Edge[nb_edges];
- vertices = new Vertex[nb_vertices];
-
- source = &vertices[src];
- sink = &vertices[snk];
-
- for(int v = 0; v < nb_vertices; v++) {
- vertices[v].id = v;
- }