ResGraphWrapper mods.
7 #include <list_graph.h>
8 //#include <smart_graph.h>
10 #include <hugo/time_measure.h>
11 #include <for_each_macros.h>
12 #include <bfs_iterator.h>
13 #include <bipartite_graph_wrapper.h>
14 #include <hugo/maps.h>
18 * Inicializalja a veletlenszamgeneratort.
19 * Figyelem, ez nem jo igazi random szamokhoz,
20 * erre ne bizzad a titkaidat!
24 unsigned int seed = getpid();
32 * Egy veletlen int-et ad vissza 0 es m-1 kozott.
36 return int( double(m) * rand() / (RAND_MAX + 1.0) );
42 //typedef UndirListGraph Graph;
43 typedef BipartiteGraph<ListGraph> Graph;
45 typedef Graph::Node Node;
46 typedef Graph::NodeIt NodeIt;
47 typedef Graph::Edge Edge;
48 typedef Graph::EdgeIt EdgeIt;
49 typedef Graph::OutEdgeIt OutEdgeIt;
53 std::vector<Graph::Node> s_nodes;
54 std::vector<Graph::Node> t_nodes;
57 std::cout << "number of nodes in the first color class=";
60 std::cout << "number of nodes in the second color class=";
63 std::cout << "number of edges=";
66 std::cout << "Generatig a random bipartite graph..." << std::endl;
67 for (int i=0; i<a; ++i) s_nodes.push_back(g.addNode(false));
68 for (int i=0; i<b; ++i) t_nodes.push_back(g.addNode(true));
71 for(int i=0; i<m; ++i) {
72 g.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
75 // std::cout << "Edges of the bipartite graph:" << std::endl;
76 // FOR_EACH_LOC(EdgeIt, e, g) std::cout << e << " ";
77 // std::cout << std::endl;
79 // std::cout << "Nodes:" << std::endl;
80 // FOR_EACH_LOC(Graph::NodeIt, v, g) std::cout << v << " ";
81 // std::cout << std::endl;
82 // std::cout << "Nodes in T:" << std::endl;
83 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
84 // std::cout << std::endl;
85 // std::cout << "Nodes in S:" << std::endl;
86 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
87 // std::cout << std::endl;
89 // std::cout << "Erasing the first node..." << std::endl;
93 // std::cout << "Nodes of the bipartite graph:" << std::endl;
94 // FOR_EACH_GLOB(n, g) std::cout << n << " ";
95 // std::cout << std::endl;
97 // std::cout << "Nodes in T:" << std::endl;
98 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
99 // std::cout << std::endl;
100 // std::cout << "Nodes in S:" << std::endl;
101 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
102 // std::cout << std::endl;
104 typedef stGraphWrapper<Graph> stGW;
106 ConstMap<stGW::Edge, int> const1map(1);
110 stGW::EdgeMap<int> flow(stgw);
111 MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
112 max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow);
114 // while (max_flow_test.augmentOnShortestPath()) { }
115 // typedef ListGraph MutableGraph;
116 // while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
117 // while (max_flow_test.augmentOnBlockingFlow2()) {
118 // std::cout << max_flow_test.flowValue() << std::endl;
120 std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl;
121 std::cout << "elapsed time: " << ts << std::endl;
122 // FOR_EACH_LOC(stGW::EdgeIt, e, stgw) {
123 // if (flow[e]) std::cout << e << std::endl;
125 // std::cout << std::endl;