[Lemon-commits] [lemon_svn] marci: r272 - hugo/trunk/src/work/marci

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:38:28 CET 2006


Author: marci
Date: Wed Mar 17 16:41:00 2004
New Revision: 272

Modified:
   hugo/trunk/src/work/marci/max_bipartite_matching_demo.cc

Log:
.


Modified: hugo/trunk/src/work/marci/max_bipartite_matching_demo.cc
==============================================================================
--- hugo/trunk/src/work/marci/max_bipartite_matching_demo.cc	(original)
+++ hugo/trunk/src/work/marci/max_bipartite_matching_demo.cc	Wed Mar 17 16:41:00 2004
@@ -55,24 +55,46 @@
   std::vector<Node> s_nodes;
   std::vector<Node> t_nodes;
 
-  for(int i=0; i<20; ++i) {
+  for(int i=0; i<4; ++i) {
     s_nodes.push_back(G.addNode());
   }
-  for(int i=0; i<20; ++i) {
+  for(int i=0; i<4; ++i) {
     t_nodes.push_back(G.addNode());
   }
-  random_init();
-  for(int i=0; i<50; ++i) {
-    G.addEdge(s_nodes[random(20)], t_nodes[random(20)]);
-  }
+//   random_init();
+//   for(int i=0; i<6; ++i) {
+//     G.addEdge(s_nodes[random(4)], t_nodes[random(4)]);
+//   }
+  
+  G.addEdge(s_nodes[2], t_nodes[4-4]);
+  G.addEdge(s_nodes[2], t_nodes[7-4]);
+  G.addEdge(s_nodes[2], t_nodes[4-4]);
+  G.addEdge(s_nodes[3], t_nodes[6-4]);
+  G.addEdge(s_nodes[3], t_nodes[5-4]);
+  G.addEdge(s_nodes[3], t_nodes[5-4]);
+
+
   Graph::NodeMap<bool> s_map(G); //false
   Graph::NodeMap<bool> t_map(G); //false
   
-  for(int i=0; i<20; ++i) {
+  for(int i=0; i<4; ++i) {
     s_map.set(s_nodes[i], true);
     t_map.set(t_nodes[i], true);
   }
 
+  cout << "bfs and dfs iterator demo on the directed graph" << endl;
+  for(NodeIt n=G.first<NodeIt>(); G.valid(n); G.next(n)) { 
+    cout << G.id(n) << ": ";
+    cout << "out edges: ";
+    for(OutEdgeIt e=G.first<OutEdgeIt>(n); G.valid(e); G.next(e)) 
+      cout << G.id(G.tail(e)) << "->" << G.id(G.head(e)) << " ";
+    cout << "in edges: ";
+    for(InEdgeIt e=G.first<InEdgeIt>(n); G.valid(e); G.next(e)) 
+      cout << G.id(G.tail(e)) << "->" << G.id(G.head(e)) << " ";
+    cout << endl;
+  }
+
+
   {
     std::cout << "on-the-fly max bipartite matching demo on wrapped leda graph..." << std::endl;
     Graph::EdgeMap<int> flow(G); //0 flow
@@ -92,11 +114,17 @@
       ++i; 
     }
 
-//   std::cout << "maximum flow: "<< std::endl;
-//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) { 
-//     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
-//   }
-//   std::cout<<std::endl;
+    std::cout << "maximum matching: "<< std::endl;
+    for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e))  
+      if (flow.get(e))
+	std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
+    std::cout<<std::endl;
+    std::cout << "edges which are not in this maximum matching: "<< std::endl;
+    for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e))  
+      if (!flow.get(e))
+	std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
+    std::cout<<std::endl;
+    
     std::cout << "elapsed time: " << ts << std::endl;
     std::cout << "number of augmentation phases: " << i << std::endl; 
     std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;



More information about the Lemon-commits mailing list