That's what I wanted.
6 #include <list_graph.h>
7 //#include <smart_graph.h>
9 #include <hugo/time_measure.h>
10 #include <for_each_macros.h>
11 #include <bfs_iterator.h>
12 #include <bipartite_graph_wrapper.h>
13 #include <hugo/maps.h>
15 #include <graph_gen.h>
16 #include <max_bipartite_matching.h>
21 //typedef UndirListGraph Graph;
22 typedef BipartiteGraph<ListGraph> Graph;
24 typedef Graph::Node Node;
25 typedef Graph::NodeIt NodeIt;
26 typedef Graph::Edge Edge;
27 typedef Graph::EdgeIt EdgeIt;
28 typedef Graph::OutEdgeIt OutEdgeIt;
33 std::cout << "number of nodes in the first color class=";
36 std::cout << "number of nodes in the second color class=";
39 std::cout << "number of edges=";
42 std::cout << "Generatig a random bipartite graph..." << std::endl;
44 randomBipartiteGraph(g, a, b, m);
46 // std::cout << "Edges of the bipartite graph:" << std::endl;
47 // FOR_EACH_LOC(EdgeIt, e, g) std::cout << e << " ";
48 // std::cout << std::endl;
50 // std::cout << "Nodes:" << std::endl;
51 // FOR_EACH_LOC(Graph::NodeIt, v, g) std::cout << v << " ";
52 // std::cout << std::endl;
53 // std::cout << "Nodes in T:" << std::endl;
54 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
55 // std::cout << std::endl;
56 // std::cout << "Nodes in S:" << std::endl;
57 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
58 // std::cout << std::endl;
60 // std::cout << "Erasing the first node..." << std::endl;
64 // std::cout << "Nodes of the bipartite graph:" << std::endl;
65 // FOR_EACH_GLOB(n, g) std::cout << n << " ";
66 // std::cout << std::endl;
68 // std::cout << "Nodes in T:" << std::endl;
69 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
70 // std::cout << std::endl;
71 // std::cout << "Nodes in S:" << std::endl;
72 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
73 // std::cout << std::endl;
75 typedef stGraphWrapper<Graph> stGW;
77 ConstMap<stGW::Edge, int> const1map(1);
81 stGW::EdgeMap<int> flow(stgw);
82 MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
83 max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow);
85 // while (max_flow_test.augmentOnShortestPath()) { }
86 // typedef ListGraph MutableGraph;
87 // while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
88 // while (max_flow_test.augmentOnBlockingFlow2()) {
89 // std::cout << max_flow_test.flowValue() << std::endl;
91 std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl;
92 std::cout << "elapsed time: " << ts << std::endl;
93 // FOR_EACH_LOC(stGW::EdgeIt, e, stgw) {
94 // if (flow[e]) std::cout << e << std::endl;
96 std::cout << std::endl;
98 typedef ConstMap<Graph::Edge, int> EdgeCap;
100 typedef ConstMap<Graph::Node, int> NodeCap;
102 typedef Graph::EdgeMap<int> EdgeFlow;
104 typedef Graph::NodeMap<int> NodeFlow;
107 typedef stGraphWrapper<Graph>::EdgeMapWrapper<EdgeCap, NodeCap> CapMap;
108 typedef stGraphWrapper<Graph>::EdgeMapWrapper<EdgeFlow, NodeFlow> FlowMap;
110 FlowMap fm(gef, gnf);
114 //stGW::EdgeMap<int> flow(stgw);
115 MaxFlow<stGW, int, CapMap, FlowMap>
116 max_flow_test1(stgw, stgw.S_NODE, stgw.T_NODE, cm, fm);
117 max_flow_test1.run();
118 // while (max_flow_test.augmentOnShortestPath()) { }
119 // typedef ListGraph MutableGraph;
120 // while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
121 // while (max_flow_test.augmentOnBlockingFlow2()) {
122 // std::cout << max_flow_test.flowValue() << std::endl;
124 std::cout << "max flow value: " << max_flow_test1.flowValue() << std::endl;
125 std::cout << "elapsed time: " << ts << std::endl;
126 // FOR_EACH_LOC(Graph::EdgeIt, e, g) {
127 // if (gef[e]) std::cout << e << std::endl;
129 std::cout << std::endl;
132 FOR_EACH_LOC(Graph::EdgeIt, e, g) gef.set(e, 0);
133 FOR_EACH_LOC(Graph::NodeIt, n, g) gnf.set(n, 0);
134 MaxMatching<Graph, ConstMap<Graph::Edge, int>, ConstMap<Graph::Node, int>,
135 Graph::EdgeMap<int>, Graph::NodeMap<int> >
136 matching_test(g, ge1, gn1, gef, gnf);
139 std::cout << "max flow value: " << matching_test.matchingValue() << std::endl;
140 std::cout << "elapsed time: " << ts << std::endl;
141 // FOR_EACH_LOC(Graph::EdgeIt, e, g) {
142 // if (gef[e]) std::cout << e << std::endl;
144 std::cout << std::endl;
147 FOR_EACH_LOC(Graph::EdgeIt, e, g) gef.set(e, 0);
148 //FOR_EACH_LOC(Graph::NodeIt, n, g) gnf.set(n, 0);
149 MaxMatching<Graph, ConstMap<Graph::Edge, int>, ConstMap<Graph::Node, int>,
150 Graph::EdgeMap<int>, Graph::NodeMap<int> >
151 matching_test_1(g, ge1, gn1, gef/*, gnf*/);
152 matching_test_1.run();
154 std::cout << "max flow value: " << matching_test_1.matchingValue() << std::endl;
155 std::cout << "elapsed time: " << ts << std::endl;
156 // FOR_EACH_LOC(Graph::EdgeIt, e, g) {
157 // if (gef[e]) std::cout << e << std::endl;
159 std::cout << std::endl;