Index: src/work/marci/bipartite_graph_wrapper.h
===================================================================
--- src/work/marci/bipartite_graph_wrapper.h	(revision 502)
+++ src/work/marci/bipartite_graph_wrapper.h	(revision 510)
@@ -311,5 +311,5 @@
 //invalid, 3, invalid)
     template <typename T> class NodeMap;
-    template <typename T, typename Parent> class EdgeMap;
+    template <typename T> class EdgeMap;
 
 //    template <typename T> friend class NodeMap;
@@ -386,5 +386,5 @@
       friend class GraphWrapper<Graph>;
       friend class stGraphWrapper<Graph>;
-      template <typename T, typename Parent> friend class EdgeMap;
+      template <typename T> friend class EdgeMap;
       int spec;
       typename Graph::Node n;
@@ -413,4 +413,5 @@
       friend std::ostream& operator<< (std::ostream& os, const Edge& i);
       int getSpec() const { return spec; }
+      typename Graph::Node getNode() const { return n; }
     };
 
@@ -703,4 +704,5 @@
     template<typename T> class NodeMap : public GraphWrapper<Graph>::template NodeMap<T> { 
       typedef typename GraphWrapper<Graph>::template NodeMap<T> Parent;
+    protected:
       T s_value, t_value;
     public:
@@ -715,12 +717,9 @@
 	case 0: 
 	  return Parent::operator[](n);
-	  break;
 	case 1:
 	  return s_value;
-	  break;
 	case 2: 
 	default:
 	  return t_value;
-	  break;
 	}
       }
@@ -741,9 +740,48 @@
     };
 
-    template<typename T, 
-	     typename Parent=
-	     typename GraphWrapper<Graph>::template EdgeMap<T> > 
-    class EdgeMap : public Parent { 
-      //typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent;
+    /// This class is to wrap a node-map of \c Graph and two variables 
+    /// storing values for \c S_NODE and \c T_NODE to a node-map of 
+    /// stGraphWrapper<Graph>.
+    template<typename NM> class NodeMapWrapper { 
+    public:
+      typedef Node KeyType;
+      typedef typename NM::ValueType ValueType;
+    protected:
+      NM* nm;
+      ValueType* s_value, t_value;
+    public:
+      NodeMapWrapper(NM& _nm, ValueType& _s_value, ValueType& _t_value) : 
+	nm(&_nm), s_value(&_s_value), t_value(&_t_value) { }
+      ValueType operator[](const Node& n) const { 
+	switch (n.getSpec()) {
+	case 0: 
+	  return (*nm)[n];
+	case 1:
+	  return *s_value;
+	case 2: 
+	default:
+	  return *t_value;
+	}
+      }
+      void set(const Node& n, ValueType t) { 
+	switch (n.getSpec()) {
+	case 0: 
+	  nm->set(n, t);
+	  break;
+	case 1:
+	  *s_value=t;
+	  break;
+	case 2:
+	default:
+	  *t_value=t;
+	  break;
+	}
+      }
+    };
+
+    template<typename T> 
+    class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> { 
+      typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent;
+    protected:
       typename GraphWrapper<Graph>::template NodeMap<T> node_value;
     public:
@@ -756,12 +794,9 @@
 	case 0: 
 	  return Parent::operator[](e);
-	  break;
 	case 1:
 	  return node_value[e.n];
-	  break;
 	case 2:
 	default:
 	  return node_value[e.n];
-	  break;
 	}
       }
@@ -782,41 +817,43 @@
     };
 
-//     template<typename T> class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> { 
-//       typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent;
-//       typename GraphWrapper<Graph>::template NodeMap<T> node_value;
-//     public:
-//       EdgeMap(const stGraphWrapper<Graph>& _G) : Parent(_G), 
-// 						 node_value(_G) { }
-//       EdgeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a), 
-// 						      node_value(_G, a) { }
-//       T operator[](const Edge& e) const { 
-// 	switch (e.spec) {
-// 	case 0: 
-// 	  return Parent::operator[](e);
-// 	  break;
-// 	case 1:
-// 	  return node_value[e.n];
-// 	  break;
-// 	case 2:
-// 	default:
-// 	  return node_value[e.n];
-// 	  break;
-// 	}
-//       }
-//       void set(const Edge& e, T t) { 
-// 	switch (e.spec) {
-// 	case 0: 
-// 	  GraphWrapper<Graph>::template EdgeMap<T>::set(e, t);
-// 	  break;
-// 	case 1:
-// 	  node_value.set(e.n, t);
-// 	  break;
-// 	case 2:
-// 	default:
-// 	  node_value.set(e.n, t);
-// 	  break;
-// 	}
-//       }
-//     };
+    /// This class is to wrap an edge-map and a node-map of \c Graph 
+    /// to an edge-map of stGraphWrapper<Graph>.
+    template<typename EM, typename NM> 
+    class EdgeMapWrapper {
+    public: 
+      typedef Edge KeyType;
+      typedef typename EM::ValueType ValueType;
+    protected:
+      EM* em;
+      NM* nm;
+    public:
+      EdgeMapWrapper(EM& _em, NM& _nm) : em(&_em), nm(&_nm) { }
+      ValueType operator[](const Edge& e) const { 
+	switch (e.getSpec()) {
+	case 0: 
+	  return (*em)[e];
+	case 1:
+	  return (*nm)[e.getNode()];
+	case 2:
+	default:
+	  return (*nm)[e.getNode()];
+	}
+      }
+      void set(const Edge& e, ValueType t) { 
+	switch (e.getSpec()) {
+	case 0: 
+	  em->set(e, t);
+	  break;
+	case 1:
+	  nm->set(e.getNode(), t);
+	  break;
+	case 2:
+	default:
+	  nm->set(e.getNode(), t);
+	  break;
+	}
+      }
+    };
+
 
 //  template<typename G> 
@@ -841,4 +878,4 @@
 
 
-#endif //HUGO_GRAPH_WRAPPER_H
-
+#endif //HUGO_BIPARTITE_GRAPH_WRAPPER_H
+
Index: src/work/marci/bipartite_matching_try_2.cc
===================================================================
--- src/work/marci/bipartite_matching_try_2.cc	(revision 501)
+++ src/work/marci/bipartite_matching_try_2.cc	(revision 510)
@@ -73,32 +73,32 @@
   }
 
-  std::cout << "Edges of the bipartite graph:" << std::endl;
-  FOR_EACH_LOC(EdgeIt, e, g) std::cout << e << " ";
-  std::cout << std::endl;
+//   std::cout << "Edges of the bipartite graph:" << std::endl;
+//   FOR_EACH_LOC(EdgeIt, e, g) std::cout << e << " ";
+//   std::cout << std::endl;
 
-  std::cout << "Nodes:" << std::endl;
-  FOR_EACH_LOC(Graph::NodeIt, v, g) std::cout << v << " ";
-  std::cout << std::endl;
-  std::cout << "Nodes in T:" << std::endl;
-  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
-  std::cout << std::endl;
-  std::cout << "Nodes in S:" << std::endl;
-  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
-  std::cout << std::endl;
+//   std::cout << "Nodes:" << std::endl;
+//   FOR_EACH_LOC(Graph::NodeIt, v, g) std::cout << v << " ";
+//   std::cout << std::endl;
+//   std::cout << "Nodes in T:" << std::endl;
+//   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
+//   std::cout << std::endl;
+//   std::cout << "Nodes in S:" << std::endl;
+//   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
+//   std::cout << std::endl;
 
-  std::cout << "Erasing the first node..." << std::endl;
-  NodeIt n;
-  g.first(n);
-  g.erase(n);
-  std::cout << "Nodes of the bipartite graph:" << std::endl;
-  FOR_EACH_GLOB(n, g) std::cout << n << " ";
-  std::cout << std::endl;
+//   std::cout << "Erasing the first node..." << std::endl;
+//   NodeIt n;
+//   g.first(n);
+//   g.erase(n);
+//   std::cout << "Nodes of the bipartite graph:" << std::endl;
+//   FOR_EACH_GLOB(n, g) std::cout << n << " ";
+//   std::cout << std::endl;
 
-  std::cout << "Nodes in T:" << std::endl;
-  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
-  std::cout << std::endl;
-  std::cout << "Nodes in S:" << std::endl;
-  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
-  std::cout << std::endl;
+//   std::cout << "Nodes in T:" << std::endl;
+//   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
+//   std::cout << std::endl;
+//   std::cout << "Nodes in S:" << std::endl;
+//   FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
+//   std::cout << std::endl;
 
   typedef stGraphWrapper<Graph> stGW;
@@ -120,8 +120,8 @@
   std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl;
   std::cout << "elapsed time: " << ts << std::endl;
-  FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
-    if (flow[e]) std::cout << e << std::endl; 
-  }
-  std::cout << std::endl;
+//   FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
+//     if (flow[e]) std::cout << e << std::endl; 
+//   }
+//   std::cout << std::endl;
 
   return 0;
Index: src/work/marci/bipartite_matching_try_3.cc
===================================================================
--- src/work/marci/bipartite_matching_try_3.cc	(revision 510)
+++ src/work/marci/bipartite_matching_try_3.cc	(revision 510)
@@ -0,0 +1,233 @@
+// -*- c++ -*-
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include <cstdlib>
+
+#include <list_graph.h>
+//#include <smart_graph.h>
+//#include <dimacs.h>
+#include <time_measure.h>
+#include <for_each_macros.h>
+#include <bfs_iterator.h>
+#include <bipartite_graph_wrapper.h>
+#include <maps.h>
+#include <max_flow.h>
+
+using namespace hugo;
+
+// template <typename Graph, typename EdgeCap, typename NodeCap, 
+// 	  typename EdgeFlow, typename NodeFlow>
+// class MaxMatching : public MaxFlow<stGraphWrapper<Graph>, 
+// 				   stGraphWrapper<Graph>:: EdgeMapWrapper<EdgeCan, NodeCap>, stGraphWrapper<Graph>::EdgeMapWrapper<EdgeFlow, NodeFlow> > {
+//   typedef MaxFlow<stGraphWrapper<Graph>, 
+// 		  stGraphWrapper<Graph>::EdgeMapWrapper<EdgeCan, NodeCap>, 
+// 		  stGraphWrapper<Graph>::EdgeMapWrapper<EdgeFlow, NodeFlow> >
+//   Parent;
+// protected:
+//   stGraphWrapper<Graph> gw;
+//   stGraphWrapper<Graph>::EdgeMapWrapper<EdgeCap, NodeCap> cap;
+//   stGraphWrapper<Graph>::EdgeMapWrapper<EdgeFlow, NodeFlow> flow;
+//   //graph* g;
+//   //EdgeCap* edge_cap;
+//   //EdgeFlow* edge_flow;
+// public:
+//   MaxMatching(Graph& _g, EdgeCap& _edge_cap, NodeCap& _node_cap, 
+// 	      EdgeFlow& _edge_flow, NodeFlow& _node_flow) : 
+//     MaxFlow(), gw(_g), 
+//     cap(_edge_cap, _node_cap), flow(_edge_flow, _node_flow) {
+//     Parent::set(gw, cap, flow);
+//   }
+// };
+
+template <typename Graph, typename EdgeCap, typename NodeCap, 
+	  typename EdgeFlow, typename NodeFlow>
+class MaxMatching {
+// : public MaxFlow<stGraphWrapper<Graph>, 
+// 				   stGraphWrapper<Graph>:: EdgeMapWrapper<EdgeCan, NodeCap>, stGraphWrapper<Graph>::EdgeMapWrapper<EdgeFlow, NodeFlow> > {
+//   typedef MaxFlow<stGraphWrapper<Graph>, 
+// 		  stGraphWrapper<Graph>::EdgeMapWrapper<EdgeCan, NodeCap>, 
+// 		  stGraphWrapper<Graph>::EdgeMapWrapper<EdgeFlow, NodeFlow> >
+//   Parent;
+protected:
+//   EdgeCap* edge_cap;
+//   NodeCap* node_cap;
+//   EdgeFlow* edge_flow;
+//   NodeFlow* node_flow;
+  typedef  stGraphWrapper<Graph> stGW;
+  stGW stgw;
+  typedef typename stGW::template EdgeMapWrapper<EdgeCap, NodeCap> CapMap; 
+  CapMap cap;
+  typedef typename stGW::template EdgeMapWrapper<EdgeFlow, NodeFlow> FlowMap;
+  FlowMap flow;
+  MaxFlow<stGW, int, CapMap, FlowMap> mf;
+  //graph* g;
+  //EdgeCap* edge_cap;
+  //EdgeFlow* edge_flow;
+public:
+  MaxMatching(Graph& _g, EdgeCap& _edge_cap, NodeCap& _node_cap, 
+	      EdgeFlow& _edge_flow, NodeFlow& _node_flow) : 
+    stgw(_g), 
+    cap(_edge_cap, _node_cap), flow(_edge_flow, _node_flow), 
+    mf(stgw, stgw.S_NODE, stgw.T_NODE, cap, flow) { }
+  void run() { mf.run(); } 
+  int matchingValue() { return mf.flowValue(); }
+};
+
+/**
+ * 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) );
+}
+
+int main() {
+  //typedef UndirListGraph Graph; 
+  typedef BipartiteGraph<ListGraph> Graph;
+  
+  typedef Graph::Node Node;
+  typedef Graph::NodeIt NodeIt;
+  typedef Graph::Edge Edge;
+  typedef Graph::EdgeIt EdgeIt;
+  typedef Graph::OutEdgeIt OutEdgeIt;
+
+  Graph g;
+
+  std::vector<Graph::Node> s_nodes;
+  std::vector<Graph::Node> t_nodes;
+
+  int a;
+  std::cout << "number of nodes in the first color class=";
+  std::cin >> a; 
+  int b;
+  std::cout << "number of nodes in the second color class=";
+  std::cin >> b; 
+  int m;
+  std::cout << "number of edges=";
+  std::cin >> m; 
+  
+  std::cout << "Generatig a random bipartite graph..." << std::endl;
+  for (int i=0; i<a; ++i) s_nodes.push_back(g.addNode(false));
+  for (int i=0; i<b; ++i) t_nodes.push_back(g.addNode(true));
+
+  random_init();
+  for(int i=0; i<m; ++i) {
+    g.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
+  }
+
+  std::cout << "Edges of the bipartite graph:" << std::endl;
+  FOR_EACH_LOC(EdgeIt, e, g) std::cout << e << " ";
+  std::cout << std::endl;
+
+  std::cout << "Nodes:" << std::endl;
+  FOR_EACH_LOC(Graph::NodeIt, v, g) std::cout << v << " ";
+  std::cout << std::endl;
+  std::cout << "Nodes in T:" << std::endl;
+  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
+  std::cout << std::endl;
+  std::cout << "Nodes in S:" << std::endl;
+  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
+  std::cout << std::endl;
+
+  std::cout << "Erasing the first node..." << std::endl;
+  NodeIt n;
+  g.first(n);
+  g.erase(n);
+  std::cout << "Nodes of the bipartite graph:" << std::endl;
+  FOR_EACH_GLOB(n, g) std::cout << n << " ";
+  std::cout << std::endl;
+
+  std::cout << "Nodes in T:" << std::endl;
+  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";
+  std::cout << std::endl;
+  std::cout << "Nodes in S:" << std::endl;
+  FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";
+  std::cout << std::endl;
+
+  typedef stGraphWrapper<Graph> stGW;
+  stGW stgw(g);
+  ConstMap<stGW::Edge, int> const1map(1);
+
+  Timer ts;
+  ts.reset();
+  stGW::EdgeMap<int> flow(stgw);
+  MaxFlow<stGW, int, ConstMap<stGW::Edge, int>, stGW::EdgeMap<int> > 
+    max_flow_test(stgw, stgw.S_NODE, stgw.T_NODE, const1map, flow);
+  max_flow_test.run();
+//  while (max_flow_test.augmentOnShortestPath()) { }
+//  typedef ListGraph MutableGraph;
+//  while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
+//  while (max_flow_test.augmentOnBlockingFlow2()) {
+//   std::cout << max_flow_test.flowValue() << std::endl;
+//  }
+  std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl;
+  std::cout << "elapsed time: " << ts << std::endl;
+  FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 
+    if (flow[e]) std::cout << e << std::endl; 
+  }
+  std::cout << std::endl;
+
+  typedef ConstMap<Graph::Edge, int> EdgeCap; 
+  EdgeCap ge1(1);
+  typedef ConstMap<Graph::Node, int> NodeCap;
+  NodeCap gn1(1);
+  typedef Graph::EdgeMap<int> EdgeFlow;
+  EdgeFlow gef(g); //0
+  typedef Graph::NodeMap<int> NodeFlow; 
+  NodeFlow gnf(g); //0 
+
+  typedef stGraphWrapper<Graph>::EdgeMapWrapper<EdgeCap, NodeCap> CapMap; 
+  typedef stGraphWrapper<Graph>::EdgeMapWrapper<EdgeFlow, NodeFlow> FlowMap; 
+  CapMap cm(ge1, gn1);
+  FlowMap fm(gef, gnf);
+
+  //Timer ts;
+  ts.reset();
+  //stGW::EdgeMap<int> flow(stgw);
+  MaxFlow<stGW, int, CapMap, FlowMap> 
+    max_flow_test1(stgw, stgw.S_NODE, stgw.T_NODE, cm, fm);
+  max_flow_test1.run();
+//  while (max_flow_test.augmentOnShortestPath()) { }
+//  typedef ListGraph MutableGraph;
+//  while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
+//  while (max_flow_test.augmentOnBlockingFlow2()) {
+//   std::cout << max_flow_test.flowValue() << std::endl;
+//  }
+  std::cout << "max flow value: " << max_flow_test1.flowValue() << std::endl;
+  std::cout << "elapsed time: " << ts << std::endl;
+//   FOR_EACH_LOC(Graph::EdgeIt, e, g) { 
+//     if (gef[e]) std::cout << e << std::endl; 
+//   }
+  std::cout << std::endl;
+
+  ts.reset();
+  FOR_EACH_LOC(Graph::EdgeIt, e, g) gef.set(e, 0); 
+  FOR_EACH_LOC(Graph::NodeIt, n, g) gnf.set(n, 0); 
+  MaxMatching<Graph, ConstMap<Graph::Edge, int>, ConstMap<Graph::Node, int>, 
+    Graph::EdgeMap<int>, Graph::NodeMap<int> > 
+    matching_test(g, ge1, gn1, gef, gnf);
+  matching_test.run();
+
+  std::cout << "max flow value: " << matching_test.matchingValue() << std::endl;
+  std::cout << "elapsed time: " << ts << std::endl;
+//   FOR_EACH_LOC(Graph::EdgeIt, e, g) { 
+//     if (gef[e]) std::cout << e << std::endl; 
+//   }
+  std::cout << std::endl;
+  return 0;
+}
Index: src/work/marci/makefile
===================================================================
--- src/work/marci/makefile	(revision 498)
+++ src/work/marci/makefile	(revision 510)
@@ -5,5 +5,5 @@
 
 LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
-BINARIES = max_flow_demo iterator_bfs_demo macro_test lg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_try bipartite_matching_try_2
+BINARIES = max_flow_demo iterator_bfs_demo macro_test lg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_try bipartite_matching_try_2 bipartite_matching_try_3
 #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda
 
