diff -r ee5959aa4410 -r c280de819a73 src/work/jacint/max_matching.cc --- a/src/work/jacint/max_matching.cc Sun Apr 17 18:57:22 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,270 +0,0 @@ -///Generates a random graph, and tests max_matching.h on it. -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -using namespace lemon; - -int main(int, char **) { - - typedef UndirGraph UGW; - typedef UGW::Edge Edge; - typedef UGW::EdgeIt EdgeIt; - typedef UGW::OutEdgeIt OutEdgeIt; - typedef UGW::NodeIt NodeIt; - typedef UGW::Node Node; - - UGW G; - - // random_init(); //If you want to use a random graph with a random - // number of edges and nodes. - - int i; - int j; - std::cout<<"Number of nodes: "; - std::cin >> i; - std::cout<<"Number of edges: "; - std::cin >> j; - - // readDimacs(std::cin, G); - randomGraph(G, i, j ); - - Timer ts; - bool noerror=true; - - std::cout << - "\n Testing max_matching.h on a random graph with " << - G.nodeNum() << " nodes and " << G.edgeNum() << " edges...\n" - << std::endl; - MaxMatching max_matching(G); - - - std::cout << - "Running the plain edmonds algorithm runEdmonds(0) using no heuristic... " - < 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 runEdmonds(0),"<::pos_enum> pos0(G); - max_matching.writePos(pos0); - std::cout << "OK" << std::endl; - - - std::cout << "Resetting the matching and the position by calling"<< std::endl; - std::cout<<"resetPos() and resetMatching()..."; - max_matching.resetPos(); - max_matching.resetMatching(); - std::cout <<"OK" << std::endl; - - - std::cout << "\nRunning runEdmonds(1) using the 'postpone shrink' heuristic ... " <::pos_enum> pos1(G); - max_matching.writePos(pos1); - - - std::cout << "\nStarting run() from the matching given by runEdmonds(1)... " <::pos_enum> pos2(G); - max_matching.writePos(pos2); - - - std::cout << "\nCalling resetPos() and resetMatching()..."; - max_matching.resetPos(); - max_matching.resetMatching(); - std::cout<<"OK"<::pos_enum> pos(G); - max_matching.writePos(pos); - - - std::cout<<"\nChecking if the output is a matching..."; - bool ismatching=true; - for(G.first(v); G.valid(v); G.next(v) ) - if ( G.valid(mate[v]) ) { - Node u=mate[v]; - if (mate[u]!=v) ismatching=false; - } - if ( ismatching ) std::cout<<"OK"< todo(G,true); - int num_comp=0; - for(G.first(v); G.valid(v); G.next(v) ) { - if ( pos[v]==max_matching.D && todo[v] ) { - int comp_size=1; - ++num_comp; - std::queue Q; - Q.push(v); - todo.set(v,false); - while (!Q.empty()) { - Node w=Q.front(); - Q.pop(); - OutEdgeIt e; - for(G.first(e,w); G.valid(e); G.next(e)) { - Node u=G.bNode(e); - if ( pos[u]==max_matching.D && todo[u] ) { - ++comp_size; - Q.push(u); - todo.set(u,false); - } - } - } - if ( !(comp_size % 2) ) oddcomp=false; - } - } - std::cout << "\n found " << num_comp << " component(s) of G[D],"; - if ( oddcomp ) std::cout<<" each is odd."<