alpar@1: #include <iostream>
alpar@1: #include <graph.h>
alpar@2: #include <bfs.h>
alpar@1: 
alpar@1: using namespace NEGRO;
alpar@1: using namespace std;
alpar@1: 
alpar@1: class NodeData;
alpar@1: class EdgeData;
alpar@1: 
alpar@1: typedef Graph<NodeData,EdgeData> TestGraph;
alpar@1: 
alpar@1: class NodeData
alpar@1: {
alpar@1: public:
alpar@1:   int id;
alpar@1:   bool isVis;
alpar@2:   bfs_node_data<TestGraph> bfs;
alpar@1: };
alpar@1: 
alpar@1: class EdgeData
alpar@1: {
alpar@1: public:
alpar@1:   int id;
alpar@1: };
alpar@1: 
alpar@2: typedef Graph<NodeData,EdgeData> TestGraph;
alpar@1: 
alpar@3: int main()
alpar@1: {
alpar@1:   TestGraph G;
alpar@3:   TestGraph::NodeIterator n,m;
alpar@3:   TestGraph::OutEdgeIterator e;
alpar@3:   int i;
alpar@1: 
alpar@1:   
alpar@1:   //for(i=1;i<=10;i++) G.AddNode().n=i; //Ez nagyon rossz!!!!!!!!
alpar@1:   for(i=1;i<=10;i++) G.AddNode()->id=i; //Ez a jo!!!!!!!!
alpar@1: 
alpar@1:   //n=G.AddNode();
alpar@1:   
alpar@1:    //for(i=1;i<=10;i++) cout << (G.AddNode()->n=i) << ' ';
alpar@1:    //cout << '\n';
alpar@1:  
alpar@1:   i=0;
alpar@35:   for(G.GetFirst(n);n.Valid();n++)
alpar@35:     for(G.GetFirst(m);m.Valid();++m)
alpar@1:       if(n!=m) G.AddEdge(n,m)->id=++i;
alpar@1:    
alpar@1:   cout << "Number of edges: " << i << "\n\n";
alpar@1: 
alpar@1:   TestGraph::AllEdgeIterator a;
alpar@35:   for(G.GetFirst(a);a.Valid();++a)
alpar@1:     cout << a->id << ":" << a.From()->id << "->" << a.To()->id << "   ";
alpar@1: 
alpar@1:   cout << "\n\n\n";
alpar@1:   
alpar@35:   for(G.GetFirst(n);n.Valid();++n)
alpar@1:     {
alpar@1:       cout << n->id << "->";
alpar@35:       for(G.GetFirst(e,n);e.Valid();++e)
alpar@1: 	cout << e->id << ":" << e.To()->id << ' ';
alpar@1:       cout << '\n';
alpar@1:     }
alpar@1:   
alpar@1:   cout << "\n\n\n\nB-verzio:\n\n\n";
alpar@1:   
alpar@1:   G.Clean();
alpar@1: 
alpar@1:   for(i=1;i<=10;i++) G.AddNode()->id=i;
alpar@1:   
alpar@1:   i=0;
alpar@35:   for(n=G.First();n.Valid();n++)
alpar@35:     for(m=G.First();m.Valid();++m)
alpar@1:       if(n!=m) G.AddEdge(n,m)->id=++i;
alpar@1:    
alpar@1:   ;
alpar@35:   for(n=G.First();n.Valid();++n) //Demo
alpar@1:     {
alpar@1:       e=G.First(n);
alpar@35:       while(e.Valid())
alpar@3: 	if((e->id)%2) G.Delete(e++);  //it may be nice to have a postfix ++
alpar@1: 	else ++e;
alpar@1:     }
alpar@1:   
alpar@2:   // cout << "Number of edges: " << i << "\n\n";
alpar@2: 
alpar@35:   for(a=G.First();a.Valid();++a)
alpar@1:     cout << a->id << ": " << a.From()->id << "->" << a.To()->id << "   ";
alpar@1:   
alpar@1:   cout << "\n\n\n";
alpar@1:   
alpar@35:   for(n=G.First();n.Valid();++n)
alpar@1:     {
alpar@1:       cout << n->id << "->";
alpar@35:       for(e=G.First(n);e.Valid();++e)
alpar@1: 	cout << e->id << ":" << e.To()->id << ' ';
alpar@1:       cout << '\n';
alpar@1:     }
alpar@1:   
alpar@3:   // For Marci's sake
alpar@2:   
alpar@3:   {
alpar@3:     G.Clean();
alpar@3:     
alpar@3:     for(int i=1;i<=10;i++) G.AddNode()->id=i;
alpar@3:     
alpar@3:     
alpar@3:     {  //I would'n say I'm really happy with this.
alpar@35:       int i=0;
alpar@35:       for(TestGraph::NodeIterator n(G);n.Valid();n++)
alpar@35: 	for(TestGraph::NodeIterator m(G);m.Valid();++m)
alpar@3: 	  if(n!=m) G.AddEdge(n,m)->id=++i;
alpar@3:     }
alpar@3:     
alpar@35:     for(TestGraph::NodeIterator n(G);n.Valid();++n) //Demo
alpar@3:       {
alpar@3: 	TestGraph::OutEdgeIterator e(G,n);
alpar@35: 	while(e.Valid())
alpar@3: 	  if((e->id)%2) G.Delete(e++);  //it may be nice to have a postfix ++
alpar@3: 	  else ++e;
alpar@3:       }
alpar@3:     
alpar@35:     for(TestGraph::AllEdgeIterator a(G);a.Valid();++a)
alpar@3:       cout << a->id << ": " << a.From()->id << "->" << a.To()->id << "   ";
alpar@3:     
alpar@3:     cout << "\n\n\n";
alpar@3:     
alpar@35:     for(TestGraph::NodeIterator n(G);n.Valid();++n)
alpar@3:       {
alpar@3: 	cout << n->id << "->";
alpar@35: 	for(TestGraph::OutEdgeIterator e(G,n);e.Valid();++e)
alpar@3: 	  cout << e->id << ":" << e.To()->id << ' ';
alpar@3: 	cout << '\n';
alpar@3:       }
alpar@3:   }
alpar@1: }