# HG changeset patch # User marci # Date 1084297054 0 # Node ID b5b5c4ae510772394b1b0a0362ebc91b824f86c4 # Parent 0856a9a87eb92f0c4bf624a0a4e710258ad6c21e documentation of bipartite matchings, cleaning diff -r 0856a9a87eb9 -r b5b5c4ae5107 src/work/Doxyfile --- a/src/work/Doxyfile Tue May 11 17:02:32 2004 +0000 +++ b/src/work/Doxyfile Tue May 11 17:37:34 2004 +0000 @@ -400,7 +400,8 @@ jacint/max_matching.h \ marci/bfs_dfs.h \ marci/bfs_dfs_misc.h \ - jacint/graph_gen.h + jacint/graph_gen.h \ + marci/max_bipartite_matching.h # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp diff -r 0856a9a87eb9 -r b5b5c4ae5107 src/work/marci/bipartite_matching_try_2.cc --- a/src/work/marci/bipartite_matching_try_2.cc Tue May 11 17:02:32 2004 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -// -*- c++ -*- -#include -#include -#include -#include - -#include -//#include -//#include -#include -#include -#include -#include -#include -#include - -/** - * Inicializalja a veletlenszamgeneratort. - * Figyelem, ez nem jo igazi random szamokhoz, - * erre ne bizzad a titkaidat! - */ -void random_init() -{ - unsigned int seed = getpid(); - seed |= seed << 15; - seed ^= time(0); - - srand(seed); -} - -/** - * Egy veletlen int-et ad vissza 0 es m-1 kozott. - */ -int random(int m) -{ - return int( double(m) * rand() / (RAND_MAX + 1.0) ); -} - -using namespace hugo; - -int main() { - //typedef UndirListGraph Graph; - typedef BipartiteGraph Graph; - - typedef Graph::Node Node; - typedef Graph::NodeIt NodeIt; - typedef Graph::Edge Edge; - typedef Graph::EdgeIt EdgeIt; - typedef Graph::OutEdgeIt OutEdgeIt; - - Graph g; - - std::vector s_nodes; - std::vector t_nodes; - - int a; - std::cout << "number of nodes in the first color class="; - std::cin >> a; - int b; - std::cout << "number of nodes in the second color class="; - std::cin >> b; - int m; - std::cout << "number of edges="; - std::cin >> m; - - std::cout << "Generatig a random bipartite graph..." << std::endl; - for (int i=0; i stGW; - stGW stgw(g); - ConstMap const1map(1); - - Timer ts; - ts.reset(); - stGW::EdgeMap flow(stgw); - MaxFlow, stGW::EdgeMap > - max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow); - max_flow_test.run(); -// while (max_flow_test.augmentOnShortestPath()) { } -// typedef ListGraph MutableGraph; -// while (max_flow_test.augmentOnBlockingFlow1()) { -// while (max_flow_test.augmentOnBlockingFlow2()) { -// std::cout << max_flow_test.flowValue() << std::endl; -// } - 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) { -// if (flow[e]) std::cout << e << std::endl; -// } -// std::cout << std::endl; - - return 0; -} diff -r 0856a9a87eb9 -r b5b5c4ae5107 src/work/marci/bipartite_matching_try_3.cc --- a/src/work/marci/bipartite_matching_try_3.cc Tue May 11 17:02:32 2004 +0000 +++ b/src/work/marci/bipartite_matching_try_3.cc Tue May 11 17:37:34 2004 +0000 @@ -131,7 +131,7 @@ ts.reset(); FOR_EACH_LOC(Graph::EdgeIt, e, g) gef.set(e, 0); FOR_EACH_LOC(Graph::NodeIt, n, g) gnf.set(n, 0); - MaxMatching, ConstMap, + MaxBipartiteMatching, ConstMap, Graph::EdgeMap, Graph::NodeMap > matching_test(g, ge1, gn1, gef, gnf); matching_test.run(); @@ -146,7 +146,7 @@ ts.reset(); FOR_EACH_LOC(Graph::EdgeIt, e, g) gef.set(e, 0); //FOR_EACH_LOC(Graph::NodeIt, n, g) gnf.set(n, 0); - MaxMatching, ConstMap, + MaxBipartiteMatching, ConstMap, Graph::EdgeMap, Graph::NodeMap > matching_test_1(g, ge1, gn1, gef/*, gnf*/); matching_test_1.run(); diff -r 0856a9a87eb9 -r b5b5c4ae5107 src/work/marci/makefile --- a/src/work/marci/makefile Tue May 11 17:02:32 2004 +0000 +++ b/src/work/marci/makefile Tue May 11 17:37:34 2004 +0000 @@ -4,7 +4,7 @@ INCLUDEDIRS ?= -I../.. -I.. -I../{marci,jacint,alpar,klao,akos,athos} -I$(BOOSTROOT) LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo -BINARIES = max_flow_demo iterator_bfs_demo macro_test lg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_try bipartite_matching_try_2 bipartite_matching_try_3 top_sort_test +BINARIES = max_flow_demo iterator_bfs_demo macro_test lg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_try bipartite_matching_try_3 top_sort_test #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda include ../makefile diff -r 0856a9a87eb9 -r b5b5c4ae5107 src/work/marci/max_bipartite_matching.h --- a/src/work/marci/max_bipartite_matching.h Tue May 11 17:02:32 2004 +0000 +++ b/src/work/marci/max_bipartite_matching.h Tue May 11 17:37:34 2004 +0000 @@ -33,15 +33,17 @@ // } // }; - /// A bipartite matching class. + /// \brief A bipartite matching class. + /// /// This class reduces the matching problem to a flow problem and /// a preflow is used on a wrapper. Such a generic approach means that /// matchings, b-matchings an capacitated b-matchings can be handled in /// a similar way. Due to the efficiency of the preflow algorithm, an /// efficient matching framework is obtained. + /// \ingroup galgs template - class MaxMatching { + class MaxBipartiteMatching { protected: // EdgeCap* edge_cap; // NodeCap* node_cap; @@ -65,7 +67,7 @@ /// to obtain saturation information about nodes. ///\bug Note that the values in _edge_flow and _node_flow have /// to form a flow. - MaxMatching(Graph& _g, EdgeCap& _edge_cap, NodeCap& _node_cap, + MaxBipartiteMatching(Graph& _g, EdgeCap& _edge_cap, NodeCap& _node_cap, EdgeFlow& _edge_flow, NodeFlow& _node_flow) : stgw(_g), cap(_edge_cap, _node_cap), @@ -76,7 +78,7 @@ /// this constructor is more comfortable. ///\bug Note that the values in _edge_flow and _node_flow have /// to form a flow. - MaxMatching(Graph& _g, EdgeCap& _edge_cap, NodeCap& _node_cap, + MaxBipartiteMatching(Graph& _g, EdgeCap& _edge_cap, NodeCap& _node_cap, EdgeFlow& _edge_flow/*, NodeFlow& _node_flow*/) : stgw(_g), cap(_edge_cap, _node_cap), @@ -84,7 +86,7 @@ flow(_edge_flow, *node_flow), mf(stgw, stgw.S_NODE, stgw.T_NODE, cap, flow) { } /// The class have a nontrivial destructor. - ~MaxMatching() { if (node_flow) delete node_flow; } + ~MaxBipartiteMatching() { if (node_flow) delete node_flow; } /// run computes the max matching. void run() { mf.run(); } /// The matching value after running \c run.