[Lemon-commits] [lemon_svn] alpar: r15 - in hugo/trunk/src: include work

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


Author: alpar
Date: Sat Dec 13 16:44:50 2003
New Revision: 15

Added:
   hugo/trunk/src/work/bfsdemo.cc
Modified:
   hugo/trunk/src/include/bfs.h
   hugo/trunk/src/include/graph.h
   hugo/trunk/src/include/oldgraph.h
   hugo/trunk/src/work/graphdemo.cc
   hugo/trunk/src/work/makefile

Log:
- Marci type iterator constructors
- src/demo/bfsdemo.cc: demo for bfs.h
- cosmetical changes


Modified: hugo/trunk/src/include/bfs.h
==============================================================================
--- hugo/trunk/src/include/bfs.h	(original)
+++ hugo/trunk/src/include/bfs.h	Sat Dec 13 16:44:50 2003
@@ -38,14 +38,14 @@
 //   };
   
   
-//   Nem jo! Osszeakad a masik Set-tel
+//   Nem jo! Osszeakad a masik Put-tel
 //   class do_nothing_map {};
 //   template <typename V,typename T>
-//   void Set(const do_nothing_map &p,const V &v,const T &t) {}
+//   void Put(const do_nothing_map &p,const V &v,const T &t) {}
   
   struct do_nothing_map {
   template <typename V,typename T>
-  static void Set(V v,T t) {}
+  static void Put(V v,T t) {}
   };
   
 
@@ -53,23 +53,23 @@
   class class_element_map {
   public:
     typedef T value_type;
-    static void Set(const I &i, const T &t) {(*i).*M=t;}
+    static void Put(const I &i, const T &t) {(*i).*M=t;}
     static T Get(const I i) {return (*i).*M;}
     T &operator[](I i) {return (*i).*M;}
   };
 
   /* 
      template <typename C,typename I,typename T, T C::*M>
-     void Set(class_element_map<C,T,M> p,I i, T t)
+     void Put(class_element_map<C,T,M> p,I i, T t)
      {
      i->*M=t;   
      };
   */
 
   template <typename P,typename I,typename T>
-  inline void Set(P &p,const I &i, const T &t)
+  inline void Put(P &p,const I &i, const T &t)
   {
-    p.Set(i,t);   
+    p.Put(i,t);   
   };
   template <typename P,typename I>
   inline typename P::value_type Get(const P &p,const I &i)
@@ -125,7 +125,7 @@
     public:
       bfs_node_data<G> NodeType::*d;
       typedef bool value_type;
-      void Set(typename G::NodeIterator &i, const value_type &t)
+      void Put(typename G::NodeIterator &i, const value_type &t)
       {((*i).*d).visited=t;}
       value_type Get(const typename G::NodeIterator &i) const
       {return ((*i).*d).visited;}
@@ -136,7 +136,7 @@
     public:
       bfs_node_data<G> NodeType::*d;
       typedef typename G::EdgeIterator value_type;
-      void Set(typename G::NodeIterator &i, const value_type &t)
+      void Put(typename G::NodeIterator &i, const value_type &t)
       {((*i).*d).tree=t;}
       value_type Get(const typename G::NodeIterator &i) const
       {return ((*i).*d).tree;}
@@ -147,7 +147,7 @@
     public:
       bfs_node_data<G> NodeType::*d;
       typedef int value_type;
-      void Set(typename G::NodeIterator &i, const value_type &t)
+      void Put(typename G::NodeIterator &i, const value_type &t)
       {((*i).*d).dist=t;}
       value_type Get(const typename G::NodeIterator &i) const
       {return ((*i).*d).dist;}
@@ -158,7 +158,7 @@
     public:
       bfs_node_data<G> NodeType::*d;
       typedef int value_type;
-      void Set(typename G::NodeIterator &i,  const value_type &t)
+      void Put(typename G::NodeIterator &i,  const value_type &t)
       {((*i).*d).priority=t;}
       value_type Get(const typename G::NodeIterator &i) const
       {return ((*i).*d).priority;}
@@ -175,7 +175,7 @@
     
     bfs_static_maps(const bfs_node_data<G> NodeType::*dd) 
     {
-      SetDataField(dd);
+      PutDataField(dd);
     }
     
     bfs_static_maps(const bfs_static_maps<G> &B) 
@@ -210,17 +210,17 @@
     int d;
     
     for(Gr.GetFirst(n);n.isValid();++n)
-      Set(maps.visited,n,false);
+      Put(maps.visited,n,false);
     
     queue<Q_T> Q;
     
     q.n=start_node;
     q.dist=0;
     Q.push(q);
-    Set(maps.visited,start_node,true);
-    //      Set(maps::tree,start_node,?????);
-    Set(maps.dist,start_node,0);
-    Set(maps.priority,start_node,pr++);
+    Put(maps.visited,start_node,true);
+    //      Put(maps::tree,start_node,?????);
+    Put(maps.dist,start_node,0);
+    Put(maps.priority,start_node,pr++);
     
     do {
       n=Q.front().n;d=Q.front().dist+1;
@@ -230,10 +230,10 @@
 	  q.n=m;
 	  q.dist=d;
 	  Q.push(q);
-	  Set(maps.visited,m,true);
-	  Set(maps.tree,m,e);
-	  Set(maps.dist,m,d);
-	  Set(maps.priority,m,pr++);
+	  Put(maps.visited,m,true);
+	  Put(maps.tree,m,e);
+	  Put(maps.dist,m,d);
+	  Put(maps.priority,m,pr++);
 	}
     } while(!Q.empty());
   };

Modified: hugo/trunk/src/include/graph.h
==============================================================================
--- hugo/trunk/src/include/graph.h	(original)
+++ hugo/trunk/src/include/graph.h	Sat Dec 13 16:44:50 2003
@@ -57,6 +57,8 @@
     public:    
       
       NodeIterator() {;} 
+      NodeIterator(Graph<N,E> &Gr)//'const Graph<N,E> &G' would be wrong.
+      {G=&Gr;n=Gr.OldGraph<N,E>::FirstNode();} 
       NodeIterator(const NodeIterator &i) {G=i.G;n=i.n;}
       
       NodeIterator &GoNext() { n=G->NextNode(n); return *this;}
@@ -148,6 +150,10 @@
     //Ne a BiEdgeIterator-bol szarmazzon?
     {
     public:
+      InEdgeIterator() {}
+      InEdgeIterator(const Graph<N,E> &Gr,const NodeIterator &n)
+      { G=&Gr; e=Gr.OldGraph<N,E>::FirstIn(n.n);}
+
       InEdgeIterator &GoNext() { e=e->NextIn(); return *this;}
       InEdgeIterator Next() const {return InEdgeIterator(*this).GoNext();}
       InEdgeIterator &operator++() { return GoNext();}
@@ -169,6 +175,10 @@
     class OutEdgeIterator : public EdgeIterator
     {
     public:
+      OutEdgeIterator() {}
+      OutEdgeIterator(Graph<N,E> &Gr,const NodeIterator &n)
+      { G=&Gr; e=Gr.OldGraph<N,E>::FirstOut(n.n);}
+
       OutEdgeIterator &GoNext() { e=e->NextOut(); return *this;}
       OutEdgeIterator Next() const {return OutEdgeIterator(*this).GoNext();}
       OutEdgeIterator &operator++() { return GoNext();}
@@ -192,6 +202,10 @@
       NodeIterator n;  // Itt ketszer van a G
       
     public:
+      SymEdgeIterator() {}
+      SymEdgeIterator(const Graph<N,E> &Gr,const NodeIterator &nn)
+      { G=&Gr; n=nn; e=Gr.FirstSym(nn.n); }
+
       SymEdgeIterator &GoNext() { e=e->NextEdge(n.n); return *this;}
       SymEdgeIterator Next() const {return SymEdgeIterator(*this).GoNext();}
       SymEdgeIterator &operator++() { return GoNext();}
@@ -216,6 +230,12 @@
       NodeIterator n;  // Itt ketszer van a G
       
     public:
+      AllEdgeIterator() {}
+      AllEdgeIterator(Graph<N,E> &Gr) : n(Gr)
+      {
+	e=n.isValid()?Gr.OldGraph<N,E>::FirstOut(n.n):NULL;
+      }  
+
       AllEdgeIterator &GoNext()
       {
 	e=e->NextOut();
@@ -248,7 +268,7 @@
     typedef InEdgeIterator DeletingInEdgeIterator;
     typedef SymEdgeIterator DeletingSymEdgeIterator;
     
-    const NodeIterator &FirstNode()
+    const NodeIterator FirstNode()
     {
       NodeIterator i;
       i.G=this;i.n=OldGraph<N,E>::FirstNode();
@@ -284,19 +304,19 @@
     
     
     //Vagy beginnode()?
-    const DeletingEdgeIterator &FirstOut(const NodeIterator &n)
+    const DeletingEdgeIterator FirstOut(const NodeIterator &n)
     {
       EdgeIterator i;
       i.G=n.G;i.edge=n.G->OldGraph<N,E>::FirstOut(n.n);
       return i;
     }
-    const DeletingEdgeIterator &FirstIn(const NodeIterator &n)
+    const DeletingEdgeIterator FirstIn(const NodeIterator &n)
     {
       EdgeIterator i;
       i.G=n.G;i.edge=n.G->OldGraph<N,E>::FirstIn(n.n);
       return i;
     }
-    const DeletingSymEdgeIterator &FirstSym(const NodeIterator &n)
+    const DeletingSymEdgeIterator FirstSym(const NodeIterator &n)
     {
       EdgeIterator i;
       i.G=n.G;i.n=n.n;
@@ -368,7 +388,7 @@
     void Delete(DeletingEdgeIterator e) {e.G->OldGraph<N,E>::Delete(e.e);}
     
     int NodeNum() { OldGraph<N,E>::NodeNum(); }
-    int Clean() { OldGraph<N,E>::Clean(); }
+    void Clean() { OldGraph<N,E>::Clean(); }
 
     Graph() : _FST(this) {}
   };

Modified: hugo/trunk/src/include/oldgraph.h
==============================================================================
--- hugo/trunk/src/include/oldgraph.h	(original)
+++ hugo/trunk/src/include/oldgraph.h	Sat Dec 13 16:44:50 2003
@@ -111,51 +111,52 @@
  public:
   int NodeNum() {return nodenum;};
   int EdgeNum();
-  int MaxNode() {return nodes_size;};
-  int FirstNode() {return firstnode;};
-  int NextNode(int n) {return nodes[n].next;};
-  int PrevNode(int n) {return nodes[n].prev;};
-  N& operator()(int n) {return *(N*)(nodes[n].data);};
-  N& Data      (int n) {return *(N*)(nodes[n].data);};
+  int MaxNode() const {return nodes_size;};
+  int FirstNode() const {return firstnode;};
+  int NextNode(int n) const {return nodes[n].next;};
+  int PrevNode(int n) const {return nodes[n].prev;};
+  N& operator()(int n) const {return *(N*)(nodes[n].data);};
+  N& Data      (int n) const {return *(N*)(nodes[n].data);};
   int AddNode();
-  void AddNodeBlock(int n) {for(int i=0;i<n;i++) AddNode();}
+  void AddNodeBlock(int n) const {for(int i=0;i<n;i++) AddNode();}
   int AddNode(int n);
   void Delete(int n);
-  int isaNode(int n) {return n>=0&&n<nodes_size&&nodes[n].indeg!=FREE_NODE;};
+  int isaNode(int n) const 
+        {return n>=0&&n<nodes_size&&nodes[n].indeg!=FREE_NODE;};
   
-  int InDeg(int n) {return nodes[n].indeg;};
-  int OutDeg(int n) {return nodes[n].outdeg;};
-  EdgePoint FirstIn(int n) {return nodes[n].firstin;};
-  EdgePoint FirstOut(int n) {return nodes[n].firstout;};
-
-  E& operator()(EdgePoint e) {return *(E*)(((edge_t*)e)->data);};
-  E& Data      (EdgePoint e) {return *(E*)(((edge_t*)e)->data);};
-  int From(EdgePoint e) {return e->from;};
-  int To(EdgePoint e) {return e->to;};
-  EdgePoint NextIn(EdgePoint e)
+  int InDeg(int n) const {return nodes[n].indeg;};
+  int OutDeg(int n) const {return nodes[n].outdeg;};
+  EdgePoint FirstIn(int n) const {return nodes[n].firstin;};
+  EdgePoint FirstOut(int n) const {return nodes[n].firstout;};
+
+  E& operator()(EdgePoint e) const {return *(E*)(((edge_t*)e)->data);};
+  E& Data      (EdgePoint e) const {return *(E*)(((edge_t*)e)->data);};
+  int From(EdgePoint e) const {return e->from;};
+  int To(EdgePoint e) const {return e->to;};
+  EdgePoint NextIn(EdgePoint e) const 
     {return e->nextin;};
-  EdgePoint NextOut(EdgePoint e)
+  EdgePoint NextOut(EdgePoint e)const 
     {return e->nextout;};
   EdgePoint AddEdge(int f, int t);
   void Delete(EdgePoint e);
   EdgePoint Edge(int f,int t);
   //  EdgePoint Edge(E &d)
   //    {return (EdgePoint)(((char*)&d)-(char*)&(((edge_t*)NULL)->data));};
-  E& operator()(int f, int t) {return *(E*)(((edge_t*)Edge(f,t))->data);};
-  E& Data(int f, int t) {return *(E*)(((edge_t*)Edge(f,t))->data);};
+  E& operator()(int f, int t) const {return *(E*)(((edge_t*)Edge(f,t))->data);};
+  E& Data(int f, int t) const {return *(E*)(((edge_t*)Edge(f,t))->data);};
   void Delete(int f, int t) {Delete(Edge(f,t));};
   void Reverse(EdgePoint e);
 
   // Functions for EdgeIndex
   
-  EdgePoint Edge(EdgeIndex i)
+  EdgePoint Edge(EdgeIndex i) const 
     { return (EdgePoint)(edges[i.block]->fields+i.index);};
-  EdgeIndex Index(EdgePoint e) { return e->index;};
-  EdgeIndex Index(int f, int t) { EdgePoint e; return Edge(f,t)->index; }
+  EdgeIndex Index(EdgePoint e) const { return e->index;};
+  EdgeIndex Index(int f, int t) const { EdgePoint e; return Edge(f,t)->index; }
   void Delete(EdgeIndex i) { Delete(Edge(i));};
-  E& operator()(EdgeIndex i)
+  E& operator()(EdgeIndex i) const 
      {return *(E*)(edges[i.block]->fields[i.index].data);};
-  E& Data(EdgeIndex i)
+  E& Data(EdgeIndex i) const 
      {return *(E*)(edges[i.block]->fields[i.index].data);};
   EdgePoint AddEdge(int f, int t,EdgeIndex in);
   
@@ -163,11 +164,11 @@
   
   // Operators for symmetric graphs:
 
-  EdgePoint FirstEdge(int n)
+  EdgePoint FirstEdge(int n) const 
     { return (EdgePoint)(FirstIn(n)?FirstIn(n):FirstOut(n));};
-  EdgePoint NextEdge(int n,EdgePoint e)
+  EdgePoint NextEdge(int n,EdgePoint e) const 
     { return From(e)==n?NextOut(e):(NextIn(e)?NextIn(e):FirstOut(n)); };
-  int Opposite(EdgePoint e,int n)
+  int Opposite(EdgePoint e,int n) const 
     { return From(e)+To(e)-n; };
   
   // Initializers, destructors
@@ -222,7 +223,6 @@
 
 template<class N, class E> void OldGraph<N,E>::destroy()
 {
-  edge_block *oe;
   int i;
   
   while(firstnode!=INVALID) Delete(firstnode);

Added: hugo/trunk/src/work/bfsdemo.cc
==============================================================================
--- (empty file)
+++ hugo/trunk/src/work/bfsdemo.cc	Sat Dec 13 16:44:50 2003
@@ -0,0 +1,83 @@
+#include <iostream>
+#include <graph.h>
+#include <bfs.h>
+
+using namespace NEGRO;
+using namespace std;
+
+class IGraph 
+{
+public:
+
+  //  struct NodeType {bfs_node_data<TestGraph> bfs;};
+  struct NodeType {bool isVis;};
+
+  vector<NodeType> nodes;
+  
+  class NodeIterator 
+  {
+  public:
+    IGraph *G;
+    int n;
+    NodeIterator &operator ++() { n++; return *this;}
+    NodeType &operator *() const { return G->nodes[n];}
+    NodeType *operator ->() const { return &(G->nodes[n]);}
+    bool isValid() const {return n<=5000;}
+    int Index() {return n;} //csak a kiirashoz kell
+  };
+  
+  void GetFirst(NodeIterator &i) {i.G=this;i.n=1;}
+
+  class OutEdgeIterator 
+  {    
+  public:
+    IGraph *G;
+    int f,t;
+    int gcd() { int a=f;int b=t;int c;while((c=a%b)) {a=b;b=c;} ; return b;}
+    OutEdgeIterator &operator ++() {while(++t<=5000&&gcd()==1);return *this;}
+    bool isValid() const {return t<=5000;}
+    NodeIterator From() const {NodeIterator i; i.G=G;i.n=f;return i;}
+    NodeIterator To() const {NodeIterator i; i.G=G;i.n=t;return i;}
+    NodeIterator Anode() const {return From();}
+    NodeIterator Bnode() const {return To();}
+  };
+
+  typedef OutEdgeIterator EdgeIterator;
+  void GetFirst(OutEdgeIterator &i,const NodeIterator &n)
+  {i.G=this;i.f=n.n;i.t=0;++i;}
+
+  IGraph() : nodes(5001) {}
+};
+
+class IMaps_t
+{
+public:
+//     class_element_map<IGraph::NodeIterator,
+//   		    IGraph::NodeType,
+//   		    bool,
+//   		    &IGraph::NodeType::isVis> visited;
+  struct _visited_map_t {
+    typedef bool value_type;
+    void Put(const IGraph::NodeIterator &n,const value_type &t) { n->isVis=t; }
+    value_type Get(const IGraph::NodeIterator &n) const { return n->isVis; }
+  } visited;
+  struct _tree_map_t {
+    typedef IGraph::EdgeIterator value_type;
+    void Put(const IGraph::NodeIterator &n,const value_type &t)
+    { cout << t.From().Index() << "->" << t.To().Index() << '\n'; }
+  } tree;
+  do_nothing_map dist;   //node->int (W)
+  do_nothing_map priority; //node->int (W)
+};
+
+
+int main()
+{
+  IGraph IG;
+  IMaps_t IMaps;
+
+  IGraph::NodeIterator in;
+  IG.GetFirst(in);
+  ++in;
+  bfs(IG,in,IMaps);  
+}

Modified: hugo/trunk/src/work/graphdemo.cc
==============================================================================
--- hugo/trunk/src/work/graphdemo.cc	(original)
+++ hugo/trunk/src/work/graphdemo.cc	Sat Dec 13 16:44:50 2003
@@ -26,106 +26,12 @@
 
 typedef Graph<NodeData,EdgeData> TestGraph;
 
-/*
-struct isVis_map {};
-bool Get(isVis_map p,TestGraph::NodeIterator i) { return i->isVis;}
-void Set(isVis_map p,TestGraph::NodeIterator i,bool b) {  i->isVis=b;}
-*/
-
-class my_bfs_maps
-{
-public:
-  //isVis_map visited;  //node->bool (RW)
-  class_element_map<TestGraph::NodeIterator,
-		    TestGraph::NodeType,
-		    bool,
-		    &NodeData::isVis> visited;
-  struct _tree_map_t {
-    typedef TestGraph::EdgeIterator value_type;
-    void Set(const TestGraph::NodeIterator &n,const value_type &t)
-    {
-      cout << t.From()->id << "->" << t.To()->id << '\n';
-    }
-  } tree;
-  do_nothing_map dist;   //node->int (W)
-  do_nothing_map priority; //node->int (W)
-  //priority_map priority; //node->int (W)
-};
-
-
-
-
-class IGraph 
-{
-public:
-
-  //  struct NodeType {bfs_node_data<TestGraph> bfs;};
-  struct NodeType {bool isVis;};
-
-  vector<NodeType> nodes;
-  
-  class NodeIterator 
-  {
-  public:
-    IGraph *G;
-    int n;
-    NodeIterator &operator ++() { n++; return *this;}
-    NodeType &operator *() const { return G->nodes[n];}
-    NodeType *operator ->() const { return &(G->nodes[n]);}
-    bool isValid() const {return n<=5000;}
-    int Index() {return n;} //csak a kiirashoz kell
-  };
-
-  void GetFirst(NodeIterator &i) {i.G=this;i.n=1;}
-
-  class OutEdgeIterator 
-  {    
-  public:
-    IGraph *G;
-    int f,t;
-    int gcd() { int a=f;int b=t;int c;while(c=a%b) {a=b;b=c;} ; return b;}
-    OutEdgeIterator &operator ++() {while(++t<=5000&&gcd()==1);return *this;}
-    bool isValid() const {return t<=5000;}
-    NodeIterator From() const {NodeIterator i; i.G=G;i.n=f;return i;}
-    NodeIterator To() const {NodeIterator i; i.G=G;i.n=t;return i;}
-    NodeIterator Anode() const {return From();}
-    NodeIterator Bnode() const {return To();}
-  };
-
-  typedef OutEdgeIterator EdgeIterator;
-  void GetFirst(OutEdgeIterator &i,const NodeIterator &n)
-  {i.G=this;i.f=n.n;i.t=0;++i;}
-
-  IGraph() : nodes(5000) {}
-};
-
-class IMaps_t
-{
-public:
-//     class_element_map<IGraph::NodeIterator,
-//   		    IGraph::NodeType,
-//   		    bool,
-//   		    &IGraph::NodeType::isVis> visited;
-  struct _visited_map_t {
-    typedef bool value_type;
-    void Set(const IGraph::NodeIterator &n,const value_type &t) { n->isVis=t; }
-    value_type Get(const IGraph::NodeIterator &n) const { return n->isVis; }
-  } visited;
-  struct _tree_map_t {
-    typedef IGraph::EdgeIterator value_type;
-    void Set(const IGraph::NodeIterator &n,const value_type &t)
-    { cout << t.From().Index() << "->" << t.To().Index() << '\n'; }
-  } tree;
-  do_nothing_map dist;   //node->int (W)
-  do_nothing_map priority; //node->int (W)
-};
-
-void main()
+int main()
 {
   TestGraph G;
-  TestGraph::NodeIterator n,m,o,p,q;
-  TestGraph::OutEdgeIterator e,f,g,h;
-  int i,j,k;
+  TestGraph::NodeIterator n,m;
+  TestGraph::OutEdgeIterator e;
+  int i;
 
   
   //for(i=1;i<=10;i++) G.AddNode().n=i; //Ez nagyon rossz!!!!!!!!
@@ -169,11 +75,11 @@
       if(n!=m) G.AddEdge(n,m)->id=++i;
    
   ;
-  for(n=G.First();n.isValid();++n)
+  for(n=G.First();n.isValid();++n) //Demo
     {
       e=G.First(n);
       while(e.isValid())
-	if((e->id)%2) G.Delete(e++);
+	if((e->id)%2) G.Delete(e++);  //it may be nice to have a postfix ++
 	else ++e;
     }
   
@@ -192,26 +98,40 @@
       cout << '\n';
     }
   
-  n=G.First();
-
-
-  //G.Clean();
-
-  cout << "\n\n\n BFS \n\n\n";
-  //my_bfs_maps Maps;
-  //  bfs_static_maps<TestGraph> Maps(&NodeData::bfs);
-  
-  /// bfs(G,n,Maps);
-
-  cout << '\n';
-
-  IGraph IG;
-  IMaps_t IMaps;
-
-  IGraph::NodeIterator in;
-  IG.GetFirst(in);
-  ++in;
-  bfs(IG,in,IMaps);
-  
+  // For Marci's sake
   
+  {
+    G.Clean();
+    
+    for(int i=1;i<=10;i++) G.AddNode()->id=i;
+    
+    
+    {  //I would'n say I'm really happy with this.
+      int i;
+      for(TestGraph::NodeIterator n(G);n.isValid();n++)
+	for(TestGraph::NodeIterator m(G);m.isValid();++m)
+	  if(n!=m) G.AddEdge(n,m)->id=++i;
+    }
+    
+    for(TestGraph::NodeIterator n(G);n.isValid();++n) //Demo
+      {
+	TestGraph::OutEdgeIterator e(G,n);
+	while(e.isValid())
+	  if((e->id)%2) G.Delete(e++);  //it may be nice to have a postfix ++
+	  else ++e;
+      }
+    
+    for(TestGraph::AllEdgeIterator a(G);a.isValid();++a)
+      cout << a->id << ": " << a.From()->id << "->" << a.To()->id << "   ";
+    
+    cout << "\n\n\n";
+    
+    for(TestGraph::NodeIterator n(G);n.isValid();++n)
+      {
+	cout << n->id << "->";
+	for(TestGraph::OutEdgeIterator e(G,n);e.isValid();++e)
+	  cout << e->id << ":" << e.To()->id << ' ';
+	cout << '\n';
+      }
+  }
 }

Modified: hugo/trunk/src/work/makefile
==============================================================================
--- hugo/trunk/src/work/makefile	(original)
+++ hugo/trunk/src/work/makefile	Sat Dec 13 16:44:50 2003
@@ -1,3 +1,20 @@
-graphdemo: graphdemo.cc ../include/graph.h ../include/bfs.h \
+CXXFLAGS=-g -Wall -I../include
+
+none:
+	@echo 'Please use one of these forms:'
+	@echo '   make all'
+	@echo '   make clean'
+	@echo '   make graphdemo'
+	@echo '   make bfsdemo'
+
+all: graphdemo bfsdemo
+
+clean:
+	rm graphdemo bfsdemo
+graphdemo: graphdemo.cc ../include/graph.h \
 	../include/oldgraph.h makefile
-	g++ -g -I../include -o graphdemo graphdemo.cc
+	g++ $(CXXFLAGS) -o graphdemo graphdemo.cc
+
+bfsdemo: bfsdemo.cc ../include/graph.h ../include/bfs.h \
+	../include/oldgraph.h makefile
+	g++ $(CXXFLAGS) -o bfsdemo bfsdemo.cc



More information about the Lemon-commits mailing list