[Lemon-commits] [lemon_svn] marci: r639 - hugo/trunk/src/work/marci/leda
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:40:43 CET 2006
Author: marci
Date: Thu Apr 29 18:59:00 2004
New Revision: 639
Modified:
hugo/trunk/src/work/marci/leda/bipartite_matching_leda.cc
hugo/trunk/src/work/marci/leda/bipartite_matching_leda_gen.cc
hugo/trunk/src/work/marci/leda/leda_graph_wrapper.h
Log:
corrections for leda matching files
Modified: hugo/trunk/src/work/marci/leda/bipartite_matching_leda.cc
==============================================================================
--- hugo/trunk/src/work/marci/leda/bipartite_matching_leda.cc (original)
+++ hugo/trunk/src/work/marci/leda/bipartite_matching_leda.cc Thu Apr 29 18:59:00 2004
@@ -18,8 +18,7 @@
//#include <bfs_iterator.h>
#include <graph_wrapper.h>
#include <maps.h>
-#include <edmonds_karp.h>
-#include <preflow.h>
+#include <max_flow.h>
/**
* Inicializalja a veletlenszamgeneratort.
@@ -101,10 +100,12 @@
ConstMap<stGW::Edge, int> const1map(1);
Timer ts;
- ts.reset();
- stGW::EdgeMap<int> max_flow(stgw);
+ stGW::EdgeMap<int> flow(stgw);
MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
- max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, max_flow);
+ max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow);
+
+ ts.reset();
+ FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
// while (max_flow_test.augmentOnShortestPath()) { }
typedef ListGraph MutableGraph;
// while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
@@ -113,35 +114,17 @@
}
std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl;
std::cout << "elapsed time: " << ts << std::endl;
-// FOR_EACH_LOC(stGW::EdgeIt, e, stgw) {
-// std::cout << e << ": " << max_flow[e] << "\n";
-// }
-// std::cout << "\n";
ts.reset();
- stGW::EdgeMap<int> pre_flow(stgw);
- Preflow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
- pre_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, pre_flow/*, true*/);
- pre_flow_test.run();
+ FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
+ max_flow_test.run();
std::cout << "pre flow value: " << max_flow_test.flowValue() << std::endl;
std::cout << "elapsed time: " << ts << std::endl;
-// FOR_EACH_LOC(stGW::EdgeIt, e, stgw) {
-// std::cout << e << ": " << pre_flow[e] << "\n";
-// }
-// std::cout << "\n";
ts.reset();
leda_list<leda_edge> ml=MAX_CARD_BIPARTITE_MATCHING(lg);
- // stGW::EdgeMap<int> pre_flow(stgw);
- //Preflow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
- // pre_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, pre_flow, true);
- //pre_flow_test.run();
std::cout << "leda matching value: " << ml.size() << std::endl;
std::cout << "elapsed time: " << ts << std::endl;
-// FOR_EACH_LOC(stGW::EdgeIt, e, stgw) {
-// std::cout << e << ": " << pre_flow[e] << "\n";
-// }
-// std::cout << "\n";
return 0;
}
Modified: hugo/trunk/src/work/marci/leda/bipartite_matching_leda_gen.cc
==============================================================================
--- hugo/trunk/src/work/marci/leda/bipartite_matching_leda_gen.cc (original)
+++ hugo/trunk/src/work/marci/leda/bipartite_matching_leda_gen.cc Thu Apr 29 18:59:00 2004
@@ -15,11 +15,9 @@
//#include <dimacs.h>
#include <time_measure.h>
#include <for_each_macros.h>
-//#include <bfs_iterator.h>
#include <graph_wrapper.h>
#include <maps.h>
-#include <edmonds_karp.h>
-#include <preflow.h>
+#include <max_flow.h>
/**
* Inicializalja a veletlenszamgeneratort.
@@ -78,82 +76,59 @@
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";
std::cout << "number of groups in LEDA random group graph=";
std::cin >> k;
-
+ std::cout << std::endl;
+
leda_list<leda_node> lS;
leda_list<leda_node> lT;
random_bigraph(lg, a, b, m, lS, lT, k);
-// for (int i=0; i<a; ++i) s_nodes.push_back(g.addNode());
-// for (int i=0; i<b; ++i) t_nodes.push_back(g.addNode());
-
-// random_init();
-// for(int i=0; i<m; ++i) {
-// g.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
-// }
-
Graph::NodeMap<int> ref_map(g, -1);
-
IterableBoolMap< Graph::NodeMap<int> > bipartite_map(ref_map);
-// for (int i=0; i<a; ++i) bipartite_map.insert(s_nodes[i], false);
-// for (int i=0; i<b; ++i) bipartite_map.insert(t_nodes[i], true);
+
+ //generating leda random group graph
leda_node ln;
forall(ln, lS) bipartite_map.insert(ln, false);
forall(ln, lT) bipartite_map.insert(ln, true);
+ //making bipartite graph
typedef BipartiteGraphWrapper<Graph> BGW;
BGW bgw(g, bipartite_map);
- // BGW::NodeMap<int> dbyj(bgw);
- // BGW::EdgeMap<int> dbyxcj(bgw);
+ //st-wrapper
typedef stGraphWrapper<BGW> stGW;
stGW stgw(bgw);
ConstMap<stGW::Edge, int> const1map(1);
stGW::EdgeMap<int> flow(stgw);
Timer ts;
- FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
+
ts.reset();
- // stGW::EdgeMap<int> pre_flow(stgw);
- Preflow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
- pre_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow/*, true*/);
- pre_flow_test.run();
- std::cout << "HUGO pre flow value: " << pre_flow_test.flowValue() << std::endl;
- std::cout << "elapsed time: " << ts << std::endl;
-// FOR_EACH_LOC(stGW::EdgeIt, e, stgw) {
-// std::cout << e << ": " << pre_flow[e] << "\n";
-// }
- std::cout << "\n";
+ FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
+ MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
+ max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow/*, true*/);
+ max_flow_test.run();
+ std::cout << "HUGO max matching algorithm based on preflow." << std::endl
+ << "Size of matching: "
+ << max_flow_test.flowValue() << std::endl;
+ std::cout << "elapsed time: " << ts << std::endl << std::endl;
ts.reset();
leda_list<leda_edge> ml=MAX_CARD_BIPARTITE_MATCHING(lg);
- // stGW::EdgeMap<int> pre_flow(stgw);
- //Preflow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
- // pre_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, pre_flow, true);
- //pre_flow_test.run();
- std::cout << "LEDA matching value: " << ml.size() << std::endl;
+ std::cout << "LEDA max matching algorithm." << std::endl
+ << "Size of matching: "
+ << ml.size() << std::endl;
std::cout << "elapsed time: " << ts << std::endl;
-// FOR_EACH_LOC(stGW::EdgeIt, e, stgw) {
-// std::cout << e << ": " << pre_flow[e] << "\n";
-// }
std::cout << "\n";
- FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
ts.reset();
- MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> >
- max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow);
-// while (max_flow_test.augmentOnShortestPath()) { }
+ FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0);
typedef ListGraph MutableGraph;
-// while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
- while (max_flow_test.augmentOnBlockingFlow2()) {
- std::cout << max_flow_test.flowValue() << std::endl;
- }
- std::cout << "HUGO blocking flow value: " << max_flow_test.flowValue() << std::endl;
+ while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { }
+ std::cout << "HUGO max matching algorithm based on blocking flow augmentation."
+ << std::endl << "Matching size: "
+ << max_flow_test.flowValue() << std::endl;
std::cout << "elapsed time: " << ts << std::endl;
-// FOR_EACH_LOC(stGW::EdgeIt, e, stgw) {
-// std::cout << e << ": " << max_flow[e] << "\n";
-// }
-// std::cout << "\n";
return 0;
}
Modified: hugo/trunk/src/work/marci/leda/leda_graph_wrapper.h
==============================================================================
--- hugo/trunk/src/work/marci/leda/leda_graph_wrapper.h (original)
+++ hugo/trunk/src/work/marci/leda/leda_graph_wrapper.h Thu Apr 29 18:59:00 2004
@@ -46,7 +46,7 @@
protected:
Graph* _graph;
LedaGraphWrapper() : _graph(0) { }
- setGraph(Graph& __graph) { _graph=&__graph; }
+ void setGraph(Graph& __graph) { _graph=&__graph; }
public:
//LedaGraphWrapper() { }
More information about the Lemon-commits
mailing list