// -*- c++ -*- #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; using std::cout; using std::endl; int main() { leda::graph g; typedef LedaGraphWrapper Graph; Graph G(g); typedef Graph::Node Node; typedef Graph::NodeIt NodeIt; typedef Graph::Edge Edge; typedef Graph::EdgeIt EdgeIt; typedef Graph::OutEdgeIt OutEdgeIt; typedef Graph::InEdgeIt InEdgeIt; //Node s, t; //Graph::EdgeMap cap(G); //readDimacsMaxFlow(std::cin, G, s, t, cap); std::vector s_nodes; std::vector t_nodes; for(int i=0; i<20; ++i) { s_nodes.push_back(G.addNode()); } for(int i=0; i<20; ++i) { t_nodes.push_back(G.addNode()); } random_init(); for(int i=0; i<50; ++i) { G.addEdge(s_nodes[random(20)], t_nodes[random(20)]); } Graph::NodeMap s_map(G); //false Graph::NodeMap t_map(G); //false for(int i=0; i<20; ++i) { s_map.set(s_nodes[i], true); t_map.set(t_nodes[i], true); } { std::cout << "on-the-fly max bipartite matching demo on wrapped leda graph..." << std::endl; Graph::EdgeMap flow(G); //0 flow Graph::EdgeMap cap(G, 1); Timer ts; ts.reset(); MaxMatching, Graph::EdgeMap > max_flow_test(G, s_map, t_map, flow, cap); //max_flow_test.augmentWithBlockingFlow(); int i=0; while (max_flow_test.augmentOnShortestPath()) { // for(EdgeIt e=G.template first(); e.valid(); ++e) { // std::cout<<"("<"<(); e.valid(); ++e) { // std::cout<<"("<"<