IterableMap with template ValueType. IterableBoolMap as a specialization.
Range checking warnings...
     7 #include <LEDA/graph.h>
 
     8 #include <LEDA/mcb_matching.h>
 
    11 #include <leda_graph_wrapper.h>
 
    12 #include <list_graph.h>
 
    14 #include <time_measure.h>
 
    15 #include <edmonds_karp.h>
 
    18  * Inicializalja a veletlenszamgeneratort.
 
    19  * Figyelem, ez nem jo igazi random szamokhoz,
 
    20  * erre ne bizzad a titkaidat!
 
    24 	unsigned int seed = getpid();
 
    32  * Egy veletlen int-et ad vissza 0 es m-1 kozott.
 
    36 	return int( double(m) * rand() / (RAND_MAX + 1.0) );
 
    47    typedef LedaGraphWrapper<leda::graph> Graph;
 
    49 //  typedef ListGraph Graph;
 
    52   typedef Graph::Node Node;
 
    53   typedef Graph::NodeIt NodeIt;  
 
    54   typedef Graph::Edge Edge;
 
    55   typedef Graph::EdgeIt EdgeIt;
 
    56   typedef Graph::OutEdgeIt OutEdgeIt;
 
    57   typedef Graph::InEdgeIt InEdgeIt;
 
    60   //Graph::EdgeMap<int> cap(G);
 
    61   //readDimacsMaxFlow(std::cin, G, s, t, cap);
 
    62   std::vector<Node> s_nodes;
 
    63   std::vector<Node> t_nodes;
 
    66   cout << "number of nodes in the first color class=";
 
    69   cout << "number of nodes in the second color class=";
 
    72   cout << "number of edges=";
 
    76   for(int i=0; i<a; ++i) {
 
    77     s_nodes.push_back(G.addNode());
 
    79   for(int i=0; i<a; ++i) {
 
    80     t_nodes.push_back(G.addNode());
 
    83   for(int i=0; i<m; ++i) {
 
    84     G.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
 
    87 //   G.addEdge(s_nodes[1], t_nodes[5-4]);
 
    88 //   G.addEdge(s_nodes[1], t_nodes[5-4]);
 
    89 //   G.addEdge(s_nodes[1], t_nodes[4-4]);
 
    90 //   G.addEdge(s_nodes[1], t_nodes[4-4]);
 
    91 //   G.addEdge(s_nodes[2], t_nodes[4-4]);
 
    92 //   G.addEdge(s_nodes[3], t_nodes[4-4]);
 
    94   leda_list<leda_node> A;
 
    95   leda_list<leda_node> B;
 
    96   Graph::NodeMap<bool> s_map(G); //false
 
    97   Graph::NodeMap<bool> t_map(G); //false
 
    99   for(int i=0; i<a; ++i) { s_map.set(s_nodes[i], true); A+=s_nodes[i]; }
 
   100   for(int i=0; i<b; ++i) { t_map.set(t_nodes[i], true); B+=t_nodes[i]; }
 
   102 //   cout << "bfs and dfs iterator demo on the directed graph" << endl;
 
   103 //   for(NodeIt n=G.first<NodeIt>(); G.valid(n); G.next(n)) { 
 
   104 //     cout << G.id(n) << ": ";
 
   105 //     cout << "out edges: ";
 
   106 //     for(OutEdgeIt e=G.first<OutEdgeIt>(n); G.valid(e); G.next(e)) 
 
   107 //       cout << G.id(G.tail(e)) << "->" << G.id(G.head(e)) << " ";
 
   108 //     cout << "in edges: ";
 
   109 //     for(InEdgeIt e=G.first<InEdgeIt>(n); G.valid(e); G.next(e)) 
 
   110 //       cout << G.id(G.tail(e)) << "->" << G.id(G.head(e)) << " ";
 
   116     std::cout << "on-the-fly max bipartite matching (Edmonds-Karp) demo on wrapped leda graph..." << std::endl;
 
   117     Graph::EdgeMap<int> flow(G); //0 flow
 
   118     Graph::EdgeMap<int> cap(G, 1);
 
   123     MaxMatching<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s_map, t_map, flow, cap);
 
   125     while (max_flow_test.augmentOnShortestPath()) { 
 
   126 //       for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e))  
 
   127 // 	std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
 
   128 //       std::cout<<std::endl;
 
   132 //     std::cout << "maximum matching: "<< std::endl;
 
   133 //     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e))  
 
   135 // 	std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
 
   136 //     std::cout<<std::endl;
 
   137 //     std::cout << "edges which are not in this maximum matching: "<< std::endl;
 
   138 //     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e))  
 
   140 // 	std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
 
   141 //     std::cout<<std::endl;
 
   143     std::cout << "elapsed time: " << ts << std::endl;
 
   144     std::cout << "number of augmentation phases: " << i << std::endl; 
 
   145     std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
 
   149 //     std::cout << "on-the-fly max bipartite matching demo (Hopcroft-Karp) on wrapped leda graph..." << std::endl;
 
   150 //     Graph::EdgeMap<int> flow(G); //0 flow
 
   151 //     Graph::EdgeMap<int> cap(G, 1);
 
   156 //     MaxMatching<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s_map, t_map, flow, cap);
 
   158 //     while (max_flow_test.augmentOnBlockingFlow2()) { 
 
   159 // //       for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e))  
 
   160 // // 	std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
 
   161 // //       std::cout<<std::endl;
 
   165 // //     std::cout << "maximum matching: "<< std::endl;
 
   166 // //     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e))  
 
   167 // //       if (flow.get(e))
 
   168 // // 	std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
 
   169 // //     std::cout<<std::endl;
 
   170 // //     std::cout << "edges which are not in this maximum matching: "<< std::endl;
 
   171 // //     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e))  
 
   172 // //       if (!flow.get(e))
 
   173 // // 	std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
 
   174 // //     std::cout<<std::endl;
 
   176 //     std::cout << "elapsed time: " << ts << std::endl;
 
   177 //     std::cout << "number of augmentation phases: " << i << std::endl; 
 
   178 //     std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
 
   182     std::cout << "max bipartite matching (LEDA)..." << std::endl;
 
   183     //Graph::EdgeMap<int> flow(G); //0 flow
 
   184     //Graph::EdgeMap<int> cap(G, 1);
 
   186     leda_node_array<bool> NC(g);
 
   191     //MaxMatching<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s_map, t_map, flow, cap);
 
   193     //while (max_flow_test.augmentOnShortestPath()) { ++i; }
 
   195     //leda_list<leda_edge> l=MAX_CARD_BIPARTITE_MATCHING_HK(g, A, B, NC, false);
 
   196     leda_list<leda_edge> l=MAX_CARD_BIPARTITE_MATCHING(g);    
 
   199 //     std::cout << "maximum matching: "<< std::endl;
 
   200 //     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e))  
 
   202 // 	std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
 
   203 //     std::cout<<std::endl;
 
   204 //     std::cout << "edges which are not in this maximum matching: "<< std::endl;
 
   205 //     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e))  
 
   207 // 	std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
 
   208 //     std::cout<<std::endl;
 
   211     std::cout << "elapsed time: " << ts << std::endl;
 
   212     //std::cout << "number of augmentation phases: " << i << std::endl; 
 
   213     std::cout << "flow value: "<< l.size() << std::endl;