.
7 #include <LEDA/graph.h>
8 #include <leda_graph_wrapper.h>
10 #include <time_measure.h>
11 #include <edmonds_karp.h>
14 * Inicializalja a veletlenszamgeneratort.
15 * Figyelem, ez nem jo igazi random szamokhoz,
16 * erre ne bizzad a titkaidat!
20 unsigned int seed = getpid();
28 * Egy veletlen int-et ad vissza 0 es m-1 kozott.
32 return int( double(m) * rand() / (RAND_MAX + 1.0) );
42 typedef LedaGraphWrapper<leda::graph> 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;
50 typedef Graph::InEdgeIt InEdgeIt;
53 //Graph::EdgeMap<int> cap(G);
54 //readDimacsMaxFlow(std::cin, G, s, t, cap);
55 std::vector<Node> s_nodes;
56 std::vector<Node> t_nodes;
58 for(int i=0; i<20; ++i) {
59 s_nodes.push_back(G.addNode());
61 for(int i=0; i<20; ++i) {
62 t_nodes.push_back(G.addNode());
65 for(int i=0; i<50; ++i) {
66 G.addEdge(s_nodes[random(20)], t_nodes[random(20)]);
68 Graph::NodeMap<bool> s_map; //false
69 Graph::NodeMap<bool> t_map; //false
71 for(int i=0; i<20; ++i) {
72 s_map.set(s_nodes[i], true);
73 t_map.set(t_nodes[i], true);
77 std::cout << "on-the-fly max bipartite matching demo on wrapped leda graph..." << std::endl;
78 Graph::EdgeMap<int> flow(G); //0 flow
79 Graph::EdgeMap<int> capacity(G, 1);
84 MaxMatching<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s_map, t_map, flow, cap);
85 //max_flow_test.augmentWithBlockingFlow<Graph>();
87 while (max_flow_test.augmentOnShortestPath()) {
88 // for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
89 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
91 // std::cout<<std::endl;
95 // std::cout << "maximum flow: "<< std::endl;
96 // for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
97 // std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
99 // std::cout<<std::endl;
100 std::cout << "elapsed time: " << ts << std::endl;
101 std::cout << "number of augmentation phases: " << i << std::endl;
102 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;