# HG changeset patch # User jacint # Date 1083964586 0 # Node ID 26e1cd224bdcf87e997cce4440cf4f922058f509 # Parent a00f9f1cfab8bb116b5690727e8cb819acca4e11 leda-hugo matching alg osszehasonlito diff -r a00f9f1cfab8 -r 26e1cd224bdc src/work/jacint/ledacomp.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/jacint/ledacomp.cc Fri May 07 21:16:26 2004 +0000 @@ -0,0 +1,117 @@ +// -*- 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 hugo; + +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; +}