Index: src/include/bfs.h
===================================================================
--- src/include/bfs.h	(revision 2)
+++ src/include/bfs.h	(revision 3)
@@ -39,12 +39,12 @@
   
   
-//   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) {}
   };
   
@@ -54,5 +54,5 @@
   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;}
@@ -61,5 +61,5 @@
   /* 
      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;   
@@ -68,7 +68,7 @@
 
   template <typename P,typename I,typename T>
-  inline void Set(P &p,const I &i, const T &t)
-  {
-    p.Set(i,t);   
+  inline void Put(P &p,const I &i, const T &t)
+  {
+    p.Put(i,t);   
   };
   template <typename P,typename I>
@@ -126,5 +126,5 @@
       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
@@ -137,5 +137,5 @@
       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
@@ -148,5 +148,5 @@
       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
@@ -159,5 +159,5 @@
       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
@@ -176,5 +176,5 @@
     bfs_static_maps(const bfs_node_data<G> NodeType::*dd) 
     {
-      SetDataField(dd);
+      PutDataField(dd);
     }
     
@@ -211,5 +211,5 @@
     
     for(Gr.GetFirst(n);n.isValid();++n)
-      Set(maps.visited,n,false);
+      Put(maps.visited,n,false);
     
     queue<Q_T> Q;
@@ -218,8 +218,8 @@
     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 {
@@ -231,8 +231,8 @@
 	  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());
Index: src/include/graph.h
===================================================================
--- src/include/graph.h	(revision 2)
+++ src/include/graph.h	(revision 3)
@@ -58,4 +58,6 @@
       
       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;}
       
@@ -149,4 +151,8 @@
     {
     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();}
@@ -170,4 +176,8 @@
     {
     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();}
@@ -193,4 +203,8 @@
       
     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();}
@@ -217,4 +231,10 @@
       
     public:
+      AllEdgeIterator() {}
+      AllEdgeIterator(Graph<N,E> &Gr) : n(Gr)
+      {
+	e=n.isValid()?Gr.OldGraph<N,E>::FirstOut(n.n):NULL;
+      }  
+
       AllEdgeIterator &GoNext()
       {
@@ -249,5 +269,5 @@
     typedef SymEdgeIterator DeletingSymEdgeIterator;
     
-    const NodeIterator &FirstNode()
+    const NodeIterator FirstNode()
     {
       NodeIterator i;
@@ -285,5 +305,5 @@
     
     //Vagy beginnode()?
-    const DeletingEdgeIterator &FirstOut(const NodeIterator &n)
+    const DeletingEdgeIterator FirstOut(const NodeIterator &n)
     {
       EdgeIterator i;
@@ -291,5 +311,5 @@
       return i;
     }
-    const DeletingEdgeIterator &FirstIn(const NodeIterator &n)
+    const DeletingEdgeIterator FirstIn(const NodeIterator &n)
     {
       EdgeIterator i;
@@ -297,5 +317,5 @@
       return i;
     }
-    const DeletingSymEdgeIterator &FirstSym(const NodeIterator &n)
+    const DeletingSymEdgeIterator FirstSym(const NodeIterator &n)
     {
       EdgeIterator i;
@@ -369,5 +389,5 @@
     
     int NodeNum() { OldGraph<N,E>::NodeNum(); }
-    int Clean() { OldGraph<N,E>::Clean(); }
+    void Clean() { OldGraph<N,E>::Clean(); }
 
     Graph() : _FST(this) {}
Index: src/include/oldgraph.h
===================================================================
--- src/include/oldgraph.h	(revision 1)
+++ src/include/oldgraph.h	(revision 3)
@@ -112,28 +112,29 @@
   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 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 isaNode(int n) const 
+        {return n>=0&&n<nodes_size&&nodes[n].indeg!=FREE_NODE;};
+  
+  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);
@@ -142,6 +143,6 @@
   //  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);
@@ -149,12 +150,12 @@
   // 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);
@@ -164,9 +165,9 @@
   // 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; };
   
@@ -223,5 +224,4 @@
 template<class N, class E> void OldGraph<N,E>::destroy()
 {
-  edge_block *oe;
   int i;
   
Index: src/work/bfsdemo.cc
===================================================================
--- src/work/bfsdemo.cc	(revision 3)
+++ src/work/bfsdemo.cc	(revision 3)
@@ -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);  
+}
Index: src/work/graphdemo.cc
===================================================================
--- src/work/graphdemo.cc	(revision 2)
+++ src/work/graphdemo.cc	(revision 3)
@@ -27,104 +27,10 @@
 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;
 
   
@@ -170,9 +76,9 @@
    
   ;
-  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;
     }
@@ -193,25 +99,39 @@
     }
   
-  n=G.First();
-
-
-  //G.Clean();
-
-  cout << "\n\n\n BFS \n\n\n";
-  //my_bfs_maps Maps;
-  //  bfs_static_maps<TestGraph> Maps(&NodeData::bfs);
+  // For Marci's sake
   
-  /// bfs(G,n,Maps);
-
-  cout << '\n';
-
-  IGraph IG;
-  IMaps_t IMaps;
-
-  IGraph::NodeIterator in;
-  IG.GetFirst(in);
-  ++in;
-  bfs(IG,in,IMaps);
-  
-  
+  {
+    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';
+      }
+  }
 }
Index: src/work/makefile
===================================================================
--- src/work/makefile	(revision 2)
+++ src/work/makefile	(revision 3)
@@ -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
