// -*- c++ -*- #include #include #include #include #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 lemon; int main() { //for leda graph leda::graph lg; //lg.make_undirected(); typedef LedaGraphWrapper Graph; Graph g(lg); //for UndirListGraph //typedef UndirListGraph Graph; //Graph g; typedef Graph::Node Node; typedef Graph::NodeIt NodeIt; typedef Graph::Edge Edge; typedef Graph::EdgeIt EdgeIt; typedef Graph::OutEdgeIt OutEdgeIt; std::vector s_nodes; std::vector t_nodes; int n; std::cout << "Number of nodes="; std::cin >> n; int m; std::cout << "number of edges="; std::cin >> m; std::cout << std::endl; random_graph(lg, n, m); Timer ts; // writeDimacs(std::cout, g); //for check MaxMatching max_matching(g); std::cout << "Running the edmonds algorithm run()... " < mate(g,INVALID); max_matching.writeNMapNode(mate); NodeIt v; for(g.first(v); g.valid(v); g.next(v) ) { if ( g.valid(mate[v]) ) { ++s; } } int size=(int)s/2; //size will be used as the size of a maxmatching std::cout << size << " is the size of the matching found by run(),"< ml=MAX_CARD_MATCHING(lg); std::cout << "LEDA max matching algorithm." << std::endl << "Size of matching: " << ml.size() << std::endl; std::cout << "elapsed time: " << ts << std::endl; std::cout << "\n"; return 0; }