Changeset 35:65dca0f43fba in lemon0.x for src/work/graphdemo.cc
 Timestamp:
 01/26/04 12:17:14 (20 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@48
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/work/graphdemo.cc
r3 r35 44 44 45 45 i=0; 46 for(G.GetFirst(n);n. isValid();n++)47 for(G.GetFirst(m);m. isValid();++m)46 for(G.GetFirst(n);n.Valid();n++) 47 for(G.GetFirst(m);m.Valid();++m) 48 48 if(n!=m) G.AddEdge(n,m)>id=++i; 49 49 … … 51 51 52 52 TestGraph::AllEdgeIterator a; 53 for(G.GetFirst(a);a. isValid();++a)53 for(G.GetFirst(a);a.Valid();++a) 54 54 cout << a>id << ":" << a.From()>id << ">" << a.To()>id << " "; 55 55 56 56 cout << "\n\n\n"; 57 57 58 for(G.GetFirst(n);n. isValid();++n)58 for(G.GetFirst(n);n.Valid();++n) 59 59 { 60 60 cout << n>id << ">"; 61 for(G.GetFirst(e,n);e. isValid();++e)61 for(G.GetFirst(e,n);e.Valid();++e) 62 62 cout << e>id << ":" << e.To()>id << ' '; 63 63 cout << '\n'; … … 71 71 72 72 i=0; 73 for(n=G.First();n. isValid();n++)74 for(m=G.First();m. isValid();++m)73 for(n=G.First();n.Valid();n++) 74 for(m=G.First();m.Valid();++m) 75 75 if(n!=m) G.AddEdge(n,m)>id=++i; 76 76 77 77 ; 78 for(n=G.First();n. isValid();++n) //Demo78 for(n=G.First();n.Valid();++n) //Demo 79 79 { 80 80 e=G.First(n); 81 while(e. isValid())81 while(e.Valid()) 82 82 if((e>id)%2) G.Delete(e++); //it may be nice to have a postfix ++ 83 83 else ++e; … … 86 86 // cout << "Number of edges: " << i << "\n\n"; 87 87 88 for(a=G.First();a. isValid();++a)88 for(a=G.First();a.Valid();++a) 89 89 cout << a>id << ": " << a.From()>id << ">" << a.To()>id << " "; 90 90 91 91 cout << "\n\n\n"; 92 92 93 for(n=G.First();n. isValid();++n)93 for(n=G.First();n.Valid();++n) 94 94 { 95 95 cout << n>id << ">"; 96 for(e=G.First(n);e. isValid();++e)96 for(e=G.First(n);e.Valid();++e) 97 97 cout << e>id << ":" << e.To()>id << ' '; 98 98 cout << '\n'; … … 108 108 109 109 { //I would'n say I'm really happy with this. 110 int i ;111 for(TestGraph::NodeIterator n(G);n. isValid();n++)112 for(TestGraph::NodeIterator m(G);m. isValid();++m)110 int i=0; 111 for(TestGraph::NodeIterator n(G);n.Valid();n++) 112 for(TestGraph::NodeIterator m(G);m.Valid();++m) 113 113 if(n!=m) G.AddEdge(n,m)>id=++i; 114 114 } 115 115 116 for(TestGraph::NodeIterator n(G);n. isValid();++n) //Demo116 for(TestGraph::NodeIterator n(G);n.Valid();++n) //Demo 117 117 { 118 118 TestGraph::OutEdgeIterator e(G,n); 119 while(e. isValid())119 while(e.Valid()) 120 120 if((e>id)%2) G.Delete(e++); //it may be nice to have a postfix ++ 121 121 else ++e; 122 122 } 123 123 124 for(TestGraph::AllEdgeIterator a(G);a. isValid();++a)124 for(TestGraph::AllEdgeIterator a(G);a.Valid();++a) 125 125 cout << a>id << ": " << a.From()>id << ">" << a.To()>id << " "; 126 126 127 127 cout << "\n\n\n"; 128 128 129 for(TestGraph::NodeIterator n(G);n. isValid();++n)129 for(TestGraph::NodeIterator n(G);n.Valid();++n) 130 130 { 131 131 cout << n>id << ">"; 132 for(TestGraph::OutEdgeIterator e(G,n);e. isValid();++e)132 for(TestGraph::OutEdgeIterator e(G,n);e.Valid();++e) 133 133 cout << e>id << ":" << e.To()>id << ' '; 134 134 cout << '\n';
Note: See TracChangeset
for help on using the changeset viewer.