Some commenticide was applied.
3 // Use a DIMACS max flow file as stdin.
4 // sub_graph_wrapper_demo < dimacs_max_flow_file
5 // This program computes a maximum number of edge-disjoint shortest paths
11 #include <hugo/smart_graph.h>
12 #include <hugo/dijkstra.h>
13 #include <hugo/maps.h>
14 #include <hugo/graph_wrapper.h>
15 #include <hugo/dimacs.h>
16 #include <hugo/preflow.h>
17 #include <hugo/tight_edge_filter_map.h>
26 typedef SmartGraph Graph;
28 typedef Graph::Edge Edge;
29 typedef Graph::Node Node;
30 typedef Graph::EdgeIt EdgeIt;
31 typedef Graph::NodeIt NodeIt;
32 typedef Graph::EdgeMap<int> LengthMap;
38 readDimacs(std::cin, g, length, s, t);
40 cout << "edges with lengths (of form tail--length->head): " << endl;
41 for(EdgeIt e(g); e!=INVALID; ++e)
42 cout << " " << g.id(g.tail(e)) << "--"
43 << length[e] << "->" << g.id(g.head(e)) << endl;
45 cout << "s: " << g.id(s) << " t: " << g.id(t) << endl;
47 typedef Dijkstra<Graph, LengthMap> Dijkstra;
48 Dijkstra dijkstra(g, length);
51 // This map returns true exactly for those edges which are
52 // tight w.r.t the length funcion and the potential
53 // given by the dijkstra algorithm.
54 typedef TightEdgeFilterMap<Graph, const Dijkstra::DistMap, LengthMap>
56 TightEdgeFilter tight_edge_filter(g, dijkstra.distMap(), length);
58 ConstMap<Node, bool> const_true_map(true);
59 // This graph contains exaclty the tight edges.
60 typedef SubGraphWrapper<Graph, ConstMap<Node, bool>, TightEdgeFilter> SubGW;
61 SubGW gw(g, const_true_map, tight_edge_filter);
63 ConstMap<Edge, int> const_1_map(1);
64 Graph::EdgeMap<int> flow(g, 0);
65 // Max flow between s and t in the graph of tight edges.
66 Preflow<SubGW, int, ConstMap<Edge, int>, Graph::EdgeMap<int> >
67 preflow(gw, s, t, const_1_map, flow);
70 cout << "edges of the maximum number of edge-disjoint shortest s-t paths: "
72 for(EdgeIt e(g); e!=INVALID; ++e)
74 cout << " " << g.id(g.tail(e)) << "--"
75 << length[e] << "->" << g.id(g.head(e)) << endl;