home *** CD-ROM | disk | FTP | other *** search
- #include <LEDA/graph.h>
- #include <LEDA/graph_alg.h>
-
- declare2(GRAPH,int,int);
-
- main()
- {
-
- GRAPH(int,int) G;
- nodelist A,B;
- edge e;
-
- test_bigraph(G,A,B);
-
- edge_array(int) weight1(G);
- edge_array(real) weight2(G);
-
- init_random();
-
- forall_edges(e,G)
- { int r = random(0,1000);
- G[e] = r;
- weight1[e] = r;
- weight2[e] = r/1000.0;
- }
-
-
- if (Yes("show graph? ")) G.print();
-
- float T = used_time();
-
- cout << "MAX_CARD_BIPARTITE MATCHING ";
- cout.flush();
- list(edge) M0 = MAX_CARD_BIPARTITE_MATCHING(G,A,B);
- cout << form("%5.2f sec |M| = %d\n",used_time(T), M0.length());
-
- /*
- if (Yes("output ? "))
- { newline;
- forall(e,M0) { G.print_edge(e); newline; }
- newline;
- }
- */
-
- cout << "MAX_CARD_MATCHING ";
- cout.flush();
- list(edge) M1 = MAX_CARD_MATCHING(G);
- cout << form("%5.2f sec |M| = %d\n",used_time(T), M1.length());
-
- /*
- if (Yes("output ? "))
- { newline;
- forall(e,M1) { G.print_edge(e); newline; }
- newline;
- }
- */
-
- newline;
-
- int w = 0;
-
- cout << "MAX_WEIGHT_BIPARTITE_MATCHING (int) ";
- cout.flush();
- list(edge) M2 = MAX_WEIGHT_BIPARTITE_MATCHING(G,A,B,weight1);
- forall(e,M2) w += weight1[e];
- cout << form("%5.2f sec W = %d\n",used_time(T),w);
-
- double W = 0;
-
- cout << "MAX_WEIGHT_BIPARTITE_MATCHING (real) ";
- cout.flush();
- list(edge) M3 = MAX_WEIGHT_BIPARTITE_MATCHING(G,A,B,weight2);
- forall(e,M3) W += weight2[e];
- cout << form("%5.2f sec W = %.2f\n",used_time(T),W);
-
-
-
- }
-