This is needed for the demo.
3 // Use a DIMACS max flow file as stdin.
4 // sub_graph_wrapper_demo < dimacs_max_flow_file
9 #include <hugo/smart_graph.h>
10 #include <hugo/dijkstra.h>
11 #include <hugo/maps.h>
12 #include <hugo/graph_wrapper.h>
13 #include <hugo/dimacs.h>
14 #include <hugo/preflow.h>
15 #include <tight_edge_filter_map.h>
24 typedef SmartGraph Graph;
26 typedef Graph::Edge Edge;
27 typedef Graph::Node Node;
28 typedef Graph::EdgeIt EdgeIt;
29 typedef Graph::NodeIt NodeIt;
30 typedef Graph::EdgeMap<int> LengthMap;
36 readDimacs(std::cin, g, length, s, t);
38 cout << "edges with lengths (of form tail--length->head): " << endl;
39 for(EdgeIt e(g); e!=INVALID; ++e)
40 cout << " " << g.id(g.tail(e)) << "--"
41 << length[e] << "->" << g.id(g.head(e)) << endl;
43 cout << "s: " << g.id(s) << " t: " << g.id(t) << endl;
45 typedef Dijkstra<Graph, LengthMap> Dijkstra;
46 Dijkstra dijkstra(g, length);
49 typedef TightEdgeFilterMap<Graph, const Dijkstra::DistMap, LengthMap>
51 TightEdgeFilter tight_edge_filter(g, dijkstra.distMap(), length);
53 ConstMap<Node, bool> const_true_map(true);
54 typedef SubGraphWrapper<Graph, ConstMap<Node, bool>, TightEdgeFilter> SubGW;
55 SubGW gw(g, const_true_map, tight_edge_filter);
57 ConstMap<Edge, int> const_1_map(1);
58 Graph::EdgeMap<int> flow(g, 0);
59 Preflow<SubGW, int, ConstMap<Edge, int>, Graph::EdgeMap<int> >
60 preflow(gw, s, t, const_1_map, flow);
63 cout << "edges of the maximum number of edge-disjoint shortest s-t paths: "
65 for(EdgeIt e(g); e!=INVALID; ++e)
67 cout << " " << g.id(g.tail(e)) << "--"
68 << length[e] << "->" << g.id(g.head(e)) << endl;