marci@411: // -*- c++ -*- marci@411: #include marci@411: #include marci@411: #include marci@411: #include marci@411: marci@411: #include marci@411: #include marci@411: #include marci@446: #include marci@411: marci@411: #include marci@411: #include marci@411: //#include marci@411: //#include marci@411: #include marci@411: #include marci@413: //#include marci@411: #include marci@496: #include marci@411: #include marci@482: #include marci@411: marci@411: /** marci@411: * Inicializalja a veletlenszamgeneratort. marci@411: * Figyelem, ez nem jo igazi random szamokhoz, marci@411: * erre ne bizzad a titkaidat! marci@411: */ marci@411: void random_init() marci@411: { marci@411: unsigned int seed = getpid(); marci@411: seed |= seed << 15; marci@411: seed ^= time(0); marci@411: marci@411: srand(seed); marci@411: } marci@411: marci@411: /** marci@411: * Egy veletlen int-et ad vissza 0 es m-1 kozott. marci@411: */ marci@411: int random(int m) marci@411: { marci@411: return int( double(m) * rand() / (RAND_MAX + 1.0) ); marci@411: } marci@411: marci@411: using namespace hugo; marci@411: marci@411: int main() { marci@411: //for leda graph marci@411: leda::graph lg; marci@413: //lg.make_undirected(); marci@411: typedef LedaGraphWrapper Graph; marci@411: Graph g(lg); marci@411: marci@411: //for UndirListGraph marci@411: //typedef UndirListGraph Graph; marci@411: //Graph g; marci@411: marci@411: typedef Graph::Node Node; marci@411: typedef Graph::NodeIt NodeIt; marci@411: typedef Graph::Edge Edge; marci@411: typedef Graph::EdgeIt EdgeIt; marci@411: typedef Graph::OutEdgeIt OutEdgeIt; marci@411: marci@411: std::vector s_nodes; marci@411: std::vector t_nodes; marci@411: marci@411: int a; marci@411: std::cout << "number of nodes in the first color class="; marci@411: std::cin >> a; marci@411: int b; marci@411: std::cout << "number of nodes in the second color class="; marci@411: std::cin >> b; marci@411: int m; marci@411: std::cout << "number of edges="; marci@411: std::cin >> m; marci@411: marci@411: marci@411: for (int i=0; i ref_map(g, -1); marci@411: marci@411: IterableBoolMap< Graph::NodeMap > bipartite_map(ref_map); marci@411: for (int i=0; i BGW; marci@411: BGW bgw(g, bipartite_map); marci@411: marci@411: BGW::NodeMap dbyj(bgw); marci@411: BGW::EdgeMap dbyxcj(bgw); marci@411: marci@411: typedef stGraphWrapper stGW; marci@411: stGW stgw(bgw); marci@411: ConstMap const1map(1); marci@411: marci@411: Timer ts; marci@482: stGW::EdgeMap flow(stgw); marci@482: MaxFlow, stGW::EdgeMap > marci@482: max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow); marci@482: marci@411: ts.reset(); marci@482: FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0); marci@411: // while (max_flow_test.augmentOnShortestPath()) { } marci@411: typedef ListGraph MutableGraph; marci@411: // while (max_flow_test.augmentOnBlockingFlow1()) { marci@411: while (max_flow_test.augmentOnBlockingFlow2()) { marci@411: std::cout << max_flow_test.flowValue() << std::endl; marci@411: } marci@411: std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl; marci@411: std::cout << "elapsed time: " << ts << std::endl; marci@411: marci@411: ts.reset(); marci@482: FOR_EACH_LOC(stGW::EdgeIt, e, stgw) flow.set(e, 0); marci@482: max_flow_test.run(); marci@411: std::cout << "pre flow value: " << max_flow_test.flowValue() << std::endl; marci@411: std::cout << "elapsed time: " << ts << std::endl; marci@411: marci@411: ts.reset(); marci@413: leda_list ml=MAX_CARD_BIPARTITE_MATCHING(lg); marci@413: std::cout << "leda matching value: " << ml.size() << std::endl; marci@411: std::cout << "elapsed time: " << ts << std::endl; marci@411: marci@411: return 0; marci@411: }