marci@410: // -*- c++ -*- marci@410: #include marci@410: #include marci@410: #include marci@410: #include marci@410: marci@410: #include marci@410: //#include marci@410: //#include marci@555: #include marci@410: #include marci@410: #include marci@496: #include marci@555: #include marci@480: #include marci@410: marci@410: /** marci@410: * Inicializalja a veletlenszamgeneratort. marci@410: * Figyelem, ez nem jo igazi random szamokhoz, marci@410: * erre ne bizzad a titkaidat! marci@410: */ marci@410: void random_init() marci@410: { marci@410: unsigned int seed = getpid(); marci@410: seed |= seed << 15; marci@410: seed ^= time(0); marci@410: marci@410: srand(seed); marci@410: } marci@410: marci@410: /** marci@410: * Egy veletlen int-et ad vissza 0 es m-1 kozott. marci@410: */ marci@410: int random(int m) marci@410: { marci@410: return int( double(m) * rand() / (RAND_MAX + 1.0) ); marci@410: } marci@410: marci@410: using namespace hugo; marci@410: marci@410: int main() { marci@499: //typedef UndirListGraph Graph; marci@499: typedef BipartiteGraph Graph; marci@499: marci@410: typedef Graph::Node Node; marci@410: typedef Graph::NodeIt NodeIt; marci@410: typedef Graph::Edge Edge; marci@410: typedef Graph::EdgeIt EdgeIt; marci@410: typedef Graph::OutEdgeIt OutEdgeIt; marci@410: marci@410: Graph g; marci@410: marci@410: std::vector s_nodes; marci@410: std::vector t_nodes; marci@410: marci@410: int a; marci@410: std::cout << "number of nodes in the first color class="; marci@410: std::cin >> a; marci@410: int b; marci@410: std::cout << "number of nodes in the second color class="; marci@410: std::cin >> b; marci@410: int m; marci@410: std::cout << "number of edges="; marci@410: std::cin >> m; marci@410: marci@500: std::cout << "Generatig a random bipartite graph..." << std::endl; marci@499: for (int i=0; i stGW; marci@499: stGW stgw(g); marci@499: ConstMap const1map(1); marci@410: marci@410: Timer ts; marci@410: ts.reset(); marci@499: stGW::EdgeMap flow(stgw); marci@410: MaxFlow, stGW::EdgeMap > marci@499: max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow); marci@500: max_flow_test.run(); marci@410: // while (max_flow_test.augmentOnShortestPath()) { } marci@500: // typedef ListGraph MutableGraph; marci@410: // while (max_flow_test.augmentOnBlockingFlow1()) { marci@500: // while (max_flow_test.augmentOnBlockingFlow2()) { marci@500: // std::cout << max_flow_test.flowValue() << std::endl; marci@500: // } marci@410: std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl; marci@410: std::cout << "elapsed time: " << ts << std::endl; marci@510: // FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { marci@510: // if (flow[e]) std::cout << e << std::endl; marci@510: // } marci@510: // std::cout << std::endl; marci@410: marci@410: return 0; marci@410: }