.
authoralpar
Mon, 26 Jan 2004 11:17:14 +0000
changeset 3565dca0f43fba
parent 34 2b607665c9e2
child 36 7d539ea6ad26
.
src/work/graphdemo.cc
     1.1 --- a/src/work/graphdemo.cc	Sun Jan 25 18:33:17 2004 +0000
     1.2 +++ b/src/work/graphdemo.cc	Mon Jan 26 11:17:14 2004 +0000
     1.3 @@ -43,22 +43,22 @@
     1.4     //cout << '\n';
     1.5   
     1.6    i=0;
     1.7 -  for(G.GetFirst(n);n.isValid();n++)
     1.8 -    for(G.GetFirst(m);m.isValid();++m)
     1.9 +  for(G.GetFirst(n);n.Valid();n++)
    1.10 +    for(G.GetFirst(m);m.Valid();++m)
    1.11        if(n!=m) G.AddEdge(n,m)->id=++i;
    1.12     
    1.13    cout << "Number of edges: " << i << "\n\n";
    1.14  
    1.15    TestGraph::AllEdgeIterator a;
    1.16 -  for(G.GetFirst(a);a.isValid();++a)
    1.17 +  for(G.GetFirst(a);a.Valid();++a)
    1.18      cout << a->id << ":" << a.From()->id << "->" << a.To()->id << "   ";
    1.19  
    1.20    cout << "\n\n\n";
    1.21    
    1.22 -  for(G.GetFirst(n);n.isValid();++n)
    1.23 +  for(G.GetFirst(n);n.Valid();++n)
    1.24      {
    1.25        cout << n->id << "->";
    1.26 -      for(G.GetFirst(e,n);e.isValid();++e)
    1.27 +      for(G.GetFirst(e,n);e.Valid();++e)
    1.28  	cout << e->id << ":" << e.To()->id << ' ';
    1.29        cout << '\n';
    1.30      }
    1.31 @@ -70,30 +70,30 @@
    1.32    for(i=1;i<=10;i++) G.AddNode()->id=i;
    1.33    
    1.34    i=0;
    1.35 -  for(n=G.First();n.isValid();n++)
    1.36 -    for(m=G.First();m.isValid();++m)
    1.37 +  for(n=G.First();n.Valid();n++)
    1.38 +    for(m=G.First();m.Valid();++m)
    1.39        if(n!=m) G.AddEdge(n,m)->id=++i;
    1.40     
    1.41    ;
    1.42 -  for(n=G.First();n.isValid();++n) //Demo
    1.43 +  for(n=G.First();n.Valid();++n) //Demo
    1.44      {
    1.45        e=G.First(n);
    1.46 -      while(e.isValid())
    1.47 +      while(e.Valid())
    1.48  	if((e->id)%2) G.Delete(e++);  //it may be nice to have a postfix ++
    1.49  	else ++e;
    1.50      }
    1.51    
    1.52    // cout << "Number of edges: " << i << "\n\n";
    1.53  
    1.54 -  for(a=G.First();a.isValid();++a)
    1.55 +  for(a=G.First();a.Valid();++a)
    1.56      cout << a->id << ": " << a.From()->id << "->" << a.To()->id << "   ";
    1.57    
    1.58    cout << "\n\n\n";
    1.59    
    1.60 -  for(n=G.First();n.isValid();++n)
    1.61 +  for(n=G.First();n.Valid();++n)
    1.62      {
    1.63        cout << n->id << "->";
    1.64 -      for(e=G.First(n);e.isValid();++e)
    1.65 +      for(e=G.First(n);e.Valid();++e)
    1.66  	cout << e->id << ":" << e.To()->id << ' ';
    1.67        cout << '\n';
    1.68      }
    1.69 @@ -107,29 +107,29 @@
    1.70      
    1.71      
    1.72      {  //I would'n say I'm really happy with this.
    1.73 -      int i;
    1.74 -      for(TestGraph::NodeIterator n(G);n.isValid();n++)
    1.75 -	for(TestGraph::NodeIterator m(G);m.isValid();++m)
    1.76 +      int i=0;
    1.77 +      for(TestGraph::NodeIterator n(G);n.Valid();n++)
    1.78 +	for(TestGraph::NodeIterator m(G);m.Valid();++m)
    1.79  	  if(n!=m) G.AddEdge(n,m)->id=++i;
    1.80      }
    1.81      
    1.82 -    for(TestGraph::NodeIterator n(G);n.isValid();++n) //Demo
    1.83 +    for(TestGraph::NodeIterator n(G);n.Valid();++n) //Demo
    1.84        {
    1.85  	TestGraph::OutEdgeIterator e(G,n);
    1.86 -	while(e.isValid())
    1.87 +	while(e.Valid())
    1.88  	  if((e->id)%2) G.Delete(e++);  //it may be nice to have a postfix ++
    1.89  	  else ++e;
    1.90        }
    1.91      
    1.92 -    for(TestGraph::AllEdgeIterator a(G);a.isValid();++a)
    1.93 +    for(TestGraph::AllEdgeIterator a(G);a.Valid();++a)
    1.94        cout << a->id << ": " << a.From()->id << "->" << a.To()->id << "   ";
    1.95      
    1.96      cout << "\n\n\n";
    1.97      
    1.98 -    for(TestGraph::NodeIterator n(G);n.isValid();++n)
    1.99 +    for(TestGraph::NodeIterator n(G);n.Valid();++n)
   1.100        {
   1.101  	cout << n->id << "->";
   1.102 -	for(TestGraph::OutEdgeIterator e(G,n);e.isValid();++e)
   1.103 +	for(TestGraph::OutEdgeIterator e(G,n);e.Valid();++e)
   1.104  	  cout << e->id << ":" << e.To()->id << ' ';
   1.105  	cout << '\n';
   1.106        }