[Lemon-commits] [lemon_svn] marci: r542 - in hugo/trunk/src/work: . marci

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


Author: marci
Date: Mon Apr 26 11:54:24 2004
New Revision: 542

Modified:
   hugo/trunk/src/work/list_graph.h
   hugo/trunk/src/work/makefile
   hugo/trunk/src/work/marci/bfs_iterator.h
   hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc
   hugo/trunk/src/work/marci/edmonds_karp.h
   hugo/trunk/src/work/marci/for_each_macros.h
   hugo/trunk/src/work/marci/graph_wrapper.h
   hugo/trunk/src/work/marci/leda_graph_wrapper.h
   hugo/trunk/src/work/marci/macro_test.cc
   hugo/trunk/src/work/marci/makefile

Log:
stGraphWrapper is almost working


Modified: hugo/trunk/src/work/list_graph.h
==============================================================================
--- hugo/trunk/src/work/list_graph.h	(original)
+++ hugo/trunk/src/work/list_graph.h	Mon Apr 26 11:54:24 2004
@@ -369,10 +369,17 @@
     /* stream operations, for testing purpose */
 
     friend std::ostream& operator<<(std::ostream& os, const Node& i) { 
-      os << i.node->id; return os; 
+      if (i.valid())
+	os << i.node->id; 
+      else
+	os << "invalid";
+      return os; 
     }
     friend std::ostream& operator<<(std::ostream& os, const Edge& i) { 
-      os << "(" << i.edge->_tail->id << "--" << i.edge->id << "->" << i.edge->_head->id << ")"; 
+      if (i.valid()) 
+	os << "(" << i.edge->_tail->id << "--" << i.edge->id << "->" << i.edge->_head->id << ")"; 
+      else 
+	os << "invalid";
       return os; 
     }
 

Modified: hugo/trunk/src/work/makefile
==============================================================================
--- hugo/trunk/src/work/makefile	(original)
+++ hugo/trunk/src/work/makefile	Mon Apr 26 11:54:24 2004
@@ -1,12 +1,12 @@
 INCLUDEDIRS ?= -I../include -I. -I./{marci,jacint,alpar,klao,akos}
-CXXFLAGS = -g -O0 -W -Wall $(INCLUDEDIRS) -ansi -pedantic
+CXXFLAGS = -g -O3 -W -Wall $(INCLUDEDIRS) -ansi -pedantic
 
 BINARIES ?= bin_heap_demo
 
 # Hat, ez elismerem, hogy nagyon ronda, de mukodik minden altalam
 # ismert rendszeren :-)  (Misi)
-#CXX := $(shell type -p g++-3.4 || type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++)
-CXX := $(shell type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++)
+CXX := $(shell type -p g++-3.4 || type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++)
+#CXX := $(shell type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++)
 CC := $(CXX)
 
 

Modified: hugo/trunk/src/work/marci/bfs_iterator.h
==============================================================================
--- hugo/trunk/src/work/marci/bfs_iterator.h	(original)
+++ hugo/trunk/src/work/marci/bfs_iterator.h	Mon Apr 26 11:54:24 2004
@@ -28,6 +28,9 @@
       graph(&_graph), reached(*(new ReachedMap(*graph /*, false*/))), 
       own_reached_map(true) { }
     ~BfsIterator() { if (own_reached_map) delete &reached; }
+    //s is marcked reached.
+    //if the queue is empty, then the its is pushed ant the first OutEdgeIt is processe.
+    //is the queue is not empty, then is it pushed.
     void pushAndSetReached(Node s) { 
       reached.set(s, true);
       if (bfs_queue.empty()) {
@@ -80,7 +83,7 @@
       return *this;
     }
     bool finished() const { return bfs_queue.empty(); }
-    operator OutEdgeIt () const { return actual_edge; }
+    operator OutEdgeIt() const { return actual_edge; }
     bool isBNodeNewlyReached() const { return b_node_newly_reached; }
     bool isANodeExamined() const { return !(graph->valid(actual_edge)); }
     Node aNode() const { return bfs_queue.front(); }
@@ -89,6 +92,51 @@
     const std::queue<Node>& getBfsQueue() const { return bfs_queue; }
   };  
 
+  /// Bfs searches from s for the nodes wich are not marked in 
+  /// reachedmap
+  template <typename Graph, 
+	    typename ReachedMap=typename Graph::template NodeMap<bool>, 
+	    typename PredMap
+	    =typename Graph::template NodeMap<typename Graph::Edge>, 
+	    typename DistMap=typename Graph::template NodeMap<int> > 
+  class Bfs : public BfsIterator<Graph, ReachedMap> {
+    typedef BfsIterator<Graph, ReachedMap> Parent;
+  protected:
+    typedef typename Parent::Node Node;
+    PredMap& pred;
+    DistMap& dist;
+  public:
+    Bfs<Graph, ReachedMap, PredMap, DistMap>(const Graph& _graph, ReachedMap& _reached, PredMap& _pred, DistMap& _dist) : BfsIterator<Graph, ReachedMap>(_graph, _reached), pred(&_pred), dist(&_dist) { }
+    //s is marked to be reached and pushed in the bfs queue.
+    //if the queue is empty, then the first out-edge is processed
+    //If s was not marked previously, then 
+    //in addition its pred is set to be INVALID, and dist to 0. 
+    //if s was marked previuosly, then it is simply pushed.
+    void push(Node s) { 
+      if (this->reached[s]) {
+	Parent::pushAndSetReached(s);
+      } else {
+	Parent::pushAndSetReached(s);
+	pred.set(s, INVALID);
+	dist.set(s, 0);
+      }
+    }
+    void run(Node s) {
+      push(s);
+      while (!this->finished()) this->operator++();
+    }
+    Bfs<Graph, ReachedMap, PredMap, DistMap> operator++() {
+      Parent::operator++();
+      if (this->graph->valid(actual_edge) && this->b_node_newly_reached) {
+	pred.set(s, actual_edge);
+	dist.set(s, dist[this->aNode()]);
+      }
+      return *this;
+    }
+    const PredMap& getPredMap() const { return pred; }
+    const DistMap& getDistMap() const { return dist; }
+  };
+
   template <typename Graph, /*typename OutEdgeIt,*/ 
 	    typename ReachedMap/*=typename Graph::NodeMap<bool>*/ >
   class DfsIterator {
@@ -142,7 +190,7 @@
       return *this;
     }
     bool finished() const { return dfs_stack.empty(); }
-    operator OutEdgeIt () const { return actual_edge; }
+    operator OutEdgeIt() const { return actual_edge; }
     bool isBNodeNewlyReached() const { return b_node_newly_reached; }
     bool isANodeExamined() const { return !(graph->valid(actual_edge)); }
     Node aNode() const { return actual_node; /*FIXME*/}

Modified: hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc
==============================================================================
--- hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc	(original)
+++ hugo/trunk/src/work/marci/bipartite_graph_wrapper_test.cc	Mon Apr 26 11:54:24 2004
@@ -24,22 +24,62 @@
   typedef Graph::OutEdgeIt OutEdgeIt;
 
   Graph g;
-  //Node s, t;
-  //Graph::EdgeMap<int> cap(g);
-  //readDimacsMaxFlow(std::cin, g, s, t, cap);
-  std::vector<Graph::Node> s_nodes;
-  std::vector<Graph::Node> t_nodes;
-  for (int i=0; i<3; ++i) s_nodes.push_back(g.addNode());
-  for (int i=0; i<3; ++i) t_nodes.push_back(g.addNode());
-  g.addEdge(s_nodes[0], t_nodes[2]);
-  g.addEdge(t_nodes[1], s_nodes[2]);
+//   std::vector<Graph::Node> s_nodes;
+//   std::vector<Graph::Node> t_nodes;
+//   for (int i=0; i<3; ++i) s_nodes.push_back(g.addNode());
+//   for (int i=0; i<3; ++i) t_nodes.push_back(g.addNode());
+//   g.addEdge(s_nodes[0], t_nodes[2]);
+//   g.addEdge(t_nodes[1], s_nodes[2]);
+//   g.addEdge(s_nodes[0], t_nodes[1]);
+  
+//   Graph::NodeMap<int> ref_map(g, -1);
+//   IterableBoolMap< Graph::NodeMap<int> > bipartite_map(ref_map);
+//   for (int i=0; i<3; ++i) bipartite_map.insert(s_nodes[i], false);
+//   for (int i=0; i<3; ++i) bipartite_map.insert(t_nodes[i], true);
+
+  std::vector<Graph::Node> nodes;
+  for (int i=0; i<3; ++i) nodes.push_back(g.addNode());
+  for (int i=3; i<6; ++i) nodes.push_back(g.addNode());
+  g.addEdge(nodes[0], nodes[3+2]);
+  g.addEdge(nodes[3+1], nodes[2]);
+  g.addEdge(nodes[0], nodes[3+1]);
   
   Graph::NodeMap<int> ref_map(g, -1);
   IterableBoolMap< Graph::NodeMap<int> > bipartite_map(ref_map);
-  for (int i=0; i<3; ++i) bipartite_map.insert(s_nodes[i], false);
-  for (int i=0; i<3; ++i) bipartite_map.insert(t_nodes[i], true);
+  for (int i=0; i<3; ++i) bipartite_map.insert(nodes[i], false);
+  for (int i=3; i<6; ++i) bipartite_map.insert(nodes[i], true);
+
+  Graph::Node u;
+  std::cout << "These nodes will be in S:\n";
+  //FIXME azert kellene ++, es invalid vizsgalat u-bol, hogy ezt le lehessen 
+  //irni 1etlen FOR_EACH-csel.
+  for (bipartite_map.first(u, false); g.valid(u); bipartite_map.next(u)) 
+    std::cout << u << " ";
+  std::cout << "\n";
+  std::cout << "These nodes will be in T:\n";
+  for (bipartite_map.first(u, true); g.valid(u); bipartite_map.next(u)) 
+    std::cout << u << " ";
+  std::cout << "\n";
+
   typedef BipartiteGraphWrapper<Graph> BGW;
   BGW bgw(g, bipartite_map);
+
+  std::cout << "Nodes by NodeIt:\n";
+  FOR_EACH_LOC(BGW::NodeIt, n, bgw) {
+    std::cout << n << " ";
+  }
+  std::cout << "\n";
+  std::cout << "Nodes in S by ClassNodeIt:\n";
+  FOR_EACH_INC_LOC(BGW::ClassNodeIt, n, bgw, bgw.S_CLASS) {
+    std::cout << n << " ";
+  }
+  std::cout << "\n";
+  std::cout << "Nodes in T by ClassNodeIt:\n";
+  FOR_EACH_INC_LOC(BGW::ClassNodeIt, n, bgw, bgw.T_CLASS) {
+    std::cout << n << " ";
+  }
+  std::cout << "\n";
+  std::cout << "Edges of the bipartite graph:\n";
   FOR_EACH_LOC(BGW::EdgeIt, e, bgw) {
     std::cout << bgw.tail(e) << "->" << bgw.head(e) << std::endl;
   }
@@ -58,21 +98,43 @@
   Graph::Node s; 
   s=g.first(si);
   bfs.pushAndSetReached(BGW::Node(s));
-  while (!bfs.finished()) ++bfs;
+  while (!bfs.finished()) { ++bfs; }
 
-  BGW::EdgeMap<bool> cap(bgw);
-  BGW::EdgeMap<bool> flow1(bgw);
+  FOR_EACH_LOC(stGW::NodeIt, n, stgw) { 
+    std::cout << "out-edges of " << n << ":\n"; 
+    FOR_EACH_INC_LOC(stGW::OutEdgeIt, e, stgw, n) { 
+      std::cout << " " << e << "\n";
+      std::cout << " aNode: " << stgw.aNode(e) << "\n";
+      std::cout << " bNode: " << stgw.bNode(e) << "\n";      
+    }
+    std::cout << "in-edges of " << n << ":\n"; 
+    FOR_EACH_INC_LOC(stGW::InEdgeIt, e, stgw, n) { 
+      std::cout << " " << e << "\n";
+      std::cout << " aNode: " << stgw.aNode(e) << "\n";
+      std::cout << " bNode: " << stgw.bNode(e) << "\n";     
+    }
+  }
+  std::cout << "Edges of the stGraphWrapper:\n"; 
+  FOR_EACH_LOC(stGW::EdgeIt, n, stgw) { 
+    std::cout << " " << n << "\n";
+  }
 
-  typedef ResGraphWrapper< BGW, int, BGW::EdgeMap<bool>, BGW::EdgeMap<bool> > 
-    RBGW;
-  RBGW rbgw(bgw, cap, flow1);
-  RBGW::NodeMap<int> u(rbgw);
-  
+  stGW::NodeMap<bool> b(stgw);
+  FOR_EACH_LOC(stGW::NodeIt, n, stgw) { 
+    std::cout << n << ": " << b[n] <<"\n";
+  }
 
+  std::cout << "Bfs from s: \n";
+  BfsIterator< stGW, stGW::NodeMap<bool> > bfs_stgw(stgw);
+  bfs_stgw.pushAndSetReached(stgw.S_NODE);
+  while (!bfs_stgw.finished()) { 
+    std::cout << " " << stGW::OutEdgeIt(bfs_stgw) << "\n";
+    ++bfs_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.augmentOnShortestPath();
-  max_flow_test.augmentOnShortestPath();
+  while (max_flow_test.augmentOnShortestPath()) { }
 
   std::cout << max_flow_test.flowValue() << std::endl;
 

Modified: hugo/trunk/src/work/marci/edmonds_karp.h
==============================================================================
--- hugo/trunk/src/work/marci/edmonds_karp.h	(original)
+++ hugo/trunk/src/work/marci/edmonds_karp.h	Mon Apr 26 11:54:24 2004
@@ -322,7 +322,9 @@
       typename MapGraphWrapper::template NodeMap<int> dist; 
     public:
       DistanceMap(MapGraphWrapper& _g) : g(&_g), dist(*g, g->nodeNum()) { }
-      void set(const typename MapGraphWrapper::Node& n, int a) { dist[n]=a; }
+      void set(const typename MapGraphWrapper::Node& n, int a) { 
+	dist.set(n, a); 
+      }
       int operator[](const typename MapGraphWrapper::Node& n) 
 	{ return dist[n]; }
 //       int get(const typename MapGraphWrapper::Node& n) const { 

Modified: hugo/trunk/src/work/marci/for_each_macros.h
==============================================================================
--- hugo/trunk/src/work/marci/for_each_macros.h	(original)
+++ hugo/trunk/src/work/marci/for_each_macros.h	Mon Apr 26 11:54:24 2004
@@ -4,13 +4,13 @@
 
 namespace hugo {
 
-#define FOR_EACH(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
-#define FOR_EACH_INC(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
+#define FOR_EACH_GLOB(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
+#define FOR_EACH_INC_GLOB(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
 
-#define FOR_EACH_EDGE(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
-#define FOR_EACH_NODE(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
-#define FOR_EACH_INEDGE(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
-#define FOR_EACH_OUTEDGE(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
+#define FOR_EACH_EDGE_GLOB(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
+#define FOR_EACH_NODE_GLOB(e, g) for((g).first((e)); (g).valid((e)); (g).next((e)))
+#define FOR_EACH_INEDGE_GLOB(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
+#define FOR_EACH_OUTEDGE_GLOB(e, g, v) for((g).first((e), (v)); (g).valid((e)); (g).next((e)))
 
 //   template<typename It, typename Graph> 
 //   It loopFirst(const Graph& g) const {

Modified: hugo/trunk/src/work/marci/graph_wrapper.h
==============================================================================
--- hugo/trunk/src/work/marci/graph_wrapper.h	(original)
+++ hugo/trunk/src/work/marci/graph_wrapper.h	Mon Apr 26 11:54:24 2004
@@ -923,12 +923,17 @@
     SFalseTTrueMap* s_false_t_true_map;
 
   public:
-    static const bool S_CLASS=false;
-    static const bool T_CLASS=true;
+    //marci
+    //FIXME vhogy igy kellene, csak az en forditom nem eszi meg
+    //static const bool S_CLASS=false;
+    //static const bool T_CLASS=true;
     
+    bool S_CLASS;
+    bool T_CLASS;
+
     BipartiteGraphWrapper(Graph& _graph, SFalseTTrueMap& _s_false_t_true_map) 
-      : GraphWrapper<Graph>(_graph), s_false_t_true_map(&_s_false_t_true_map) {
-    }
+      : GraphWrapper<Graph>(_graph), s_false_t_true_map(&_s_false_t_true_map), 
+      S_CLASS(false), T_CLASS(true) { }
     typedef typename GraphWrapper<Graph>::Node Node;
     //using GraphWrapper<Graph>::NodeIt;
     typedef typename GraphWrapper<Graph>::Edge Edge;
@@ -1102,7 +1107,7 @@
 //(invalid, 2, vmi)
 //invalid, 3, invalid)
     template <typename T> class NodeMap;
-    template <typename T> class EdgeMap;
+    template <typename T, typename Parent> class EdgeMap;
 
 //    template <typename T> friend class NodeMap;
 //    template <typename T> friend class EdgeMap;
@@ -1141,9 +1146,11 @@
 	return (v.spec!=u.spec || 
 		static_cast<typename Graph::Node>(u)!=
 		static_cast<typename Graph::Node>(v));
-      } 
+      }
+      friend std::ostream& operator<<(std::ostream& os, const Node& i);
       int getSpec() const { return spec; }
     };
+
     class NodeIt { 
       friend class GraphWrapper<Graph>;
       friend class stGraphWrapper<Graph>;
@@ -1155,14 +1162,15 @@
 	n(_n), spec(_spec) { }
       NodeIt(const Invalid& i) : n(i), spec(3) { }
       NodeIt(const stGraphWrapper<Graph>& _G) : n(*(_G.graph)), spec(0) { 
-	if (!_G->valid(n)) spec=1;
+	if (!_G.graph->valid(n)) spec=1;
       }
       operator Node() const { return Node(n, spec); }
     };
+
     class Edge : public Graph::Edge {
       friend class GraphWrapper<Graph>;
       friend class stGraphWrapper<Graph>;
-      template <typename T> friend class EdgeMap;
+      template <typename T, typename Parent> friend class EdgeMap;
       int spec;
       typename Graph::Node n;
     public:
@@ -1184,8 +1192,10 @@
 		static_cast<typename Graph::Edge>(v) || 
 		u.n!=v.n);
       } 
+      friend std::ostream& operator<<(std::ostream& os, const Edge& i);
       int getSpec() const { return spec; }
     };
+
     class OutEdgeIt { 
       friend class GraphWrapper<Graph>;
       friend class stGraphWrapper<Graph>;
@@ -1229,6 +1239,7 @@
       }
       operator Edge() const { return Edge(e, spec, n); }
     };
+
     class InEdgeIt { 
       friend class GraphWrapper<Graph>;
       friend class stGraphWrapper<Graph>;
@@ -1261,9 +1272,10 @@
 	    e=INVALID;
 	    spec=3;
 	    n=INVALID;
+	    break;
 	  case 2:
 	    e=INVALID;
-	    spec=1;
+	    spec=2;
 	    _G.graph->first(n, T_CLASS); //vmi->t;
 	    if (!_G.graph->valid(n)) spec=3; //Ha T ures
 	    break;
@@ -1271,6 +1283,7 @@
       }
       operator Edge() const { return Edge(e, spec, n); }
     };
+
     class EdgeIt { 
       friend class GraphWrapper<Graph>;
       friend class stGraphWrapper<Graph>;
@@ -1334,7 +1347,7 @@
       typename Graph::Node v;
       switch (i.spec) {
 	case 0: //normal edge
-	  this->graph->aNode(i.e);
+	  v=this->graph->aNode(i.e);
 	  this->graph->next(i.e);
 	  if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk
 	    if (this->graph->inSClass(v)) { //S, nincs kiel
@@ -1447,14 +1460,19 @@
     bool valid(const Node& n) const { return (n.spec<3); }
     bool valid(const Edge& e) const { return (e.spec<3); }
 
-//    int nodeNum() const { return this->graph->nodeNum(); }
-//    int edgeNum() const { return this->graph->edgeNum(); }
+    int nodeNum() const { return this->graph->nodeNum()+2; }
+    int edgeNum() const { 
+      return this->graph->edgeNum()+this->graph->nodeNum(); 
+    }
   
     Node aNode(const OutEdgeIt& e) const { return tail(e); }
     Node aNode(const InEdgeIt& e) const { return head(e); }
     Node bNode(const OutEdgeIt& e) const { return head(e); }
     Node bNode(const InEdgeIt& e) const { return tail(e); }
-  
+
+    void addNode() const { }
+    void addEdge() const { }
+    
 //    Node addNode() const { return Node(this->graph->addNode()); }
 //    Edge addEdge(const Node& tail, const Node& head) const { 
 //      return Edge(this->graph->addEdge(tail, head)); }
@@ -1468,7 +1486,9 @@
       typedef typename GraphWrapper<Graph>::template NodeMap<T> Parent;
       T s_value, t_value;
     public:
-      NodeMap(const stGraphWrapper<Graph>& _G) :  Parent(_G) { }
+      NodeMap(const stGraphWrapper<Graph>& _G) :  Parent(_G), 
+						  s_value(), 
+						  t_value() { }
       NodeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a), 
 						      s_value(a), 
 						      t_value(a) { }
@@ -1502,8 +1522,11 @@
       }
     };
 
-    template<typename T> class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> { 
-      typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent;
+    template<typename T, 
+	     typename Parent=
+	     typename GraphWrapper<Graph>::template EdgeMap<T> > 
+    class EdgeMap : public Parent { 
+      //typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent;
       typename GraphWrapper<Graph>::template NodeMap<T> node_value;
     public:
       EdgeMap(const stGraphWrapper<Graph>& _G) : Parent(_G), 
@@ -1527,7 +1550,7 @@
       void set(const Edge& e, T t) { 
 	switch (e.spec) {
 	case 0: 
-	  GraphWrapper<Graph>::template EdgeMap<T>::set(e, t);
+	  Parent::set(e, t);
 	  break;
 	case 1:
 	  node_value.set(e.n, t);
@@ -1539,6 +1562,55 @@
 	}
       }
     };
+
+//     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;
+// 	}
+//       }
+//     };
+
+    friend std::ostream& operator<<(std::ostream& os, const Node& i) { 
+      os << "(node: " << typename Graph::Node(i) << " spec: " << i.spec <<")"; 
+      return os; 
+    }
+    friend std::ostream& operator<<(std::ostream& os, const Edge& i) { 
+      os << "(edge: " << typename Graph::Edge(i) << " spec: " << i.spec << 
+	" node: " << i.n << ")"; 
+      return os; 
+    }
+
   };
 
   ///@}

Modified: hugo/trunk/src/work/marci/leda_graph_wrapper.h
==============================================================================
--- hugo/trunk/src/work/marci/leda_graph_wrapper.h	(original)
+++ hugo/trunk/src/work/marci/leda_graph_wrapper.h	Mon Apr 26 11:54:24 2004
@@ -22,8 +22,11 @@
   // @defgroup empty_graph The LedaGraphWrapper class
   // @{
 
-  /// An empty graph class.
+  /// A graph wrapperstructure for wrapping LEDA graphs in HUGO.
   
+  /// This graph wrapper class wraps LEDA graph and LEDA parametrized graph
+  /// and then the generic algorithms and wrappers of HUGO can be used 
+  /// with LEDA graphs. 
   /// This class provides all the common features of a grapf structure,
   /// however completely without implementations or real data structures
   /// behind the interface.
@@ -194,19 +197,19 @@
       return i; 
     }
 
-    template< typename It >
-    It first() const { 
-      It e;
-      first(e);
-      return e; 
-    }
-
-    template< typename It >
-    It first(Node v) const { 
-      It e;
-      first(e, v);
-      return e; 
-    }
+//     template< typename It >
+//     It first() const { 
+//       It e;
+//       first(e);
+//       return e; 
+//     }
+
+//     template< typename It >
+//     It first(Node v) const { 
+//       It e;
+//       first(e, v);
+//       return e; 
+//     }
 
     ///Gives back the head node of an edge.
     Node head(Edge e) const { 

Modified: hugo/trunk/src/work/marci/macro_test.cc
==============================================================================
--- hugo/trunk/src/work/marci/macro_test.cc	(original)
+++ hugo/trunk/src/work/marci/macro_test.cc	Mon Apr 26 11:54:24 2004
@@ -14,7 +14,7 @@
   Graph::Node n1=g.addNode();
   Graph::Node n2=g.addNode();
   Graph::NodeIt n;
-  FOR_EACH(n, g) {
+  FOR_EACH_GLOB(n, g) {
     std::cout << g.id(n) << " ";
   }
   std::cout << std::endl;

Modified: hugo/trunk/src/work/marci/makefile
==============================================================================
--- hugo/trunk/src/work/marci/makefile	(original)
+++ hugo/trunk/src/work/marci/makefile	Mon Apr 26 11:54:24 2004
@@ -9,7 +9,7 @@
 CXXFLAGS = -g -O3 -W -Wall $(INCLUDEDIRS) -ansi -pedantic -ftemplate-depth-30
 
 LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
-BINARIES = edmonds_karp_demo iterator_bfs_demo macro_test lg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test
+BINARIES = edmonds_karp_demo iterator_bfs_demo macro_test lg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_try
 #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda
 
 include ../makefile



More information about the Lemon-commits mailing list