Several changes in doc.
7 #include <LEDA/graph.h>
8 #include <LEDA/mcb_matching.h>
10 #include <LEDA/graph_gen.h>
12 #include <leda_graph_wrapper.h>
13 #include <sage_graph.h>
14 //#include <smart_graph.h>
16 #include <lemon/time_measure.h>
17 #include <for_each_macros.h>
18 #include <lemon/graph_wrapper.h>
19 #include <bipartite_graph_wrapper.h>
20 #include <lemon/maps.h>
21 #include <lemon/max_flow.h>
22 #include <augmenting_flow.h>
25 * Inicializalja a veletlenszamgeneratort.
26 * Figyelem, ez nem jo igazi random szamokhoz,
27 * erre ne bizzad a titkaidat!
31 unsigned int seed = getpid();
39 * Egy veletlen int-et ad vissza 0 es m-1 kozott.
43 return int( double(m) * rand() / (RAND_MAX + 1.0) );
46 using namespace lemon;
51 //lg.make_undirected();
52 typedef LedaGraphWrapper<leda::graph> Graph;
56 //typedef UndirSageGraph Graph;
59 typedef Graph::Node Node;
60 typedef Graph::NodeIt NodeIt;
61 typedef Graph::Edge Edge;
62 typedef Graph::EdgeIt EdgeIt;
63 typedef Graph::OutEdgeIt OutEdgeIt;
65 std::vector<Graph::Node> s_nodes;
66 std::vector<Graph::Node> t_nodes;
69 std::cout << "number of nodes in the first color class=";
72 std::cout << "number of nodes in the second color class=";
75 std::cout << "number of edges=";
78 std::cout << "A bipartite graph is a random group graph if the color classes \nA and B are partitiones to A_0, A_1, ..., A_{k-1} and B_0, B_1, ..., B_{k-1} \nas equally as possible \nand the edges from A_i goes to A_{i-1 mod k} and A_{i+1 mod k}.\n";
79 std::cout << "number of groups in LEDA random group graph=";
81 std::cout << std::endl;
83 leda_list<leda_node> lS;
84 leda_list<leda_node> lT;
85 random_bigraph(lg, a, b, m, lS, lT, k);
87 Graph::NodeMap<int> ref_map(g, -1);
88 IterableBoolMap< Graph::NodeMap<int> > bipartite_map(ref_map);
90 //generating leda random group graph
92 forall(ln, lS) bipartite_map.insert(ln, false);
93 forall(ln, lT) bipartite_map.insert(ln, true);
95 //making bipartite graph
96 typedef BipartiteGraphWrapper<Graph> BGW;
97 BGW bgw(g, bipartite_map);
101 typedef stBipartiteGraphWrapper<BGW> stGW;
103 ConstMap<stGW::Edge, int> const1map(1);
104 stGW::EdgeMap<int> flow(stgw);
109 FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
110 MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
111 max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow/*, true*/);
113 std::cout << "LEMON max matching algorithm based on preflow." << std::endl
114 << "Size of matching: "
115 << max_flow_test.flowValue() << std::endl;
116 std::cout << "elapsed time: " << ts << std::endl << std::endl;
119 leda_list<leda_edge> ml=MAX_CARD_BIPARTITE_MATCHING(lg);
120 std::cout << "LEDA max matching algorithm." << std::endl
121 << "Size of matching: "
122 << ml.size() << std::endl;
123 std::cout << "elapsed time: " << ts << std::endl;
127 FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
128 typedef SageGraph MutableGraph;
129 AugmentingFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
130 max_flow_test_1(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow/*, true*/);
131 while (max_flow_test_1.augmentOnBlockingFlow<MutableGraph>()) { }
132 std::cout << "LEMON max matching algorithm based on blocking flow augmentation."
133 << std::endl << "Matching size: "
134 << max_flow_test_1.flowValue() << std::endl;
135 std::cout << "elapsed time: " << ts << std::endl;