1.1 --- a/src/work/alpar/smart_graph_demo.cc Sun Apr 17 18:57:22 2005 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,124 +0,0 @@
1.4 -#include<smart_graph.h>
1.5 -#include<emptygraph.h>
1.6 -
1.7 -#include <iostream>
1.8 -#include <vector>
1.9 -
1.10 -using namespace lemon;
1.11 -
1.12 -typedef SmartGraph Graph;
1.13 -//typedef Graph Graph;
1.14 -
1.15 -
1.16 -Graph::OutEdgeIt safeFirstOut(const Graph &G, Graph::Node n)
1.17 -{
1.18 - return G.valid(n) ? Graph::OutEdgeIt(G,n):INVALID;
1.19 -}
1.20 -
1.21 -int main()
1.22 -{
1.23 -
1.24 - typedef Graph::Edge Edge;
1.25 - typedef Graph::InEdgeIt InEdgeIt;
1.26 - typedef Graph::OutEdgeIt OutEdgeIt;
1.27 - typedef Graph::EdgeIt EdgeIt;
1.28 - typedef Graph::Node Node;
1.29 - typedef Graph::NodeIt NodeIt;
1.30 -
1.31 - Graph G;
1.32 -
1.33 - {
1.34 - NodeIt n;
1.35 -
1.36 - for(int i=0;i<10;i++) G.addNode();
1.37 - for(G.first(n);G.valid(n);G.next(n))
1.38 - for(NodeIt m(G);m!=INVALID;G.next(m))
1.39 - if(n!=m) G.addEdge(n,m);
1.40 -
1.41 - OutEdgeIt e = safeFirstOut(G,n);
1.42 - OutEdgeIt f = safeFirstOut(G,NodeIt(G));
1.43 -
1.44 -
1.45 - InEdgeIt i(INVALID), j;
1.46 - InEdgeIt ii(i);
1.47 - ii=G.first(i,n);
1.48 - ii=G.next(i);
1.49 -
1.50 - OutEdgeIt o(INVALID), oo;
1.51 - OutEdgeIt ooo(oo);
1.52 - oo=G.first(o,n);
1.53 - oo=G.next(o);
1.54 -
1.55 - EdgeIt ei(INVALID), eie;
1.56 - EdgeIt eiee(ei);
1.57 - eie=G.first(ei);
1.58 - eie=G.next(ei);
1.59 -
1.60 - Edge eee(i);
1.61 - eee=o;
1.62 - eee=eie;
1.63 -
1.64 -
1.65 - bool tm;
1.66 - tm = G.valid(n) && G.valid(i) && G.valid(o) && G.valid(ei);
1.67 -
1.68 - std::vector<InEdgeIt> v(10);
1.69 - std::vector<InEdgeIt> w(10,INVALID);
1.70 -
1.71 - }
1.72 -
1.73 - // Test of maps
1.74 -
1.75 - G.clear();
1.76 -
1.77 - for(int i=0;i<10;i++) G.addNode();
1.78 - for(NodeIt i(G);G.valid(i);G.next(i))
1.79 - for(NodeIt j(G);G.valid(j);G.next(j))
1.80 - if(i<j) G.addEdge(i,j); //The iterators are comparable
1.81 -
1.82 - Graph::NodeMap<int> n(G);
1.83 - int count=0;
1.84 - for(NodeIt i(G);G.valid(i);G.next(i)) n[i]=count++;
1.85 -
1.86 - Graph::NodeMap<int> nn=n;
1.87 - Graph::NodeMap<double> dd=n;
1.88 -
1.89 - n = nn;
1.90 -
1.91 - dd = nn;
1.92 -
1.93 - Graph::EdgeMap<int> emap(G);
1.94 -
1.95 - // Test of SymSmartGraph
1.96 -
1.97 - {
1.98 - typedef SymSmartGraph Graph;
1.99 - typedef Graph::Edge Edge;
1.100 - typedef Graph::InEdgeIt InEdgeIt;
1.101 - typedef Graph::OutEdgeIt OutEdgeIt;
1.102 - typedef Graph::EdgeIt EdgeIt;
1.103 - typedef Graph::Node Node;
1.104 - typedef Graph::NodeIt NodeIt;
1.105 -
1.106 - Graph G;
1.107 -
1.108 - for(int i=0;i<10;i++) G.addNode();
1.109 - for(NodeIt i(G);G.valid(i);G.next(i))
1.110 - for(NodeIt j(G);G.valid(j);G.next(j))
1.111 - if(i<j) G.addEdge(i,j); //The iterators are comparable
1.112 -
1.113 - Graph::EdgeMap<int> em(G);
1.114 - Graph::SymEdgeMap<int> sm(G);
1.115 - for(EdgeIt e(G);G.valid(e);G.next(e)) em[e]=G.id(e);
1.116 - for(EdgeIt e(G);G.valid(e);G.next(e))
1.117 - if(G.source(e)<G.target(e)) sm[e]=G.id(e);
1.118 -
1.119 - for(EdgeIt e(G);G.valid(e);G.next(e))
1.120 - std::cout << G.id(G.source(e)) << "->" << G.id(G.target(e))
1.121 - << ": id=" << G.id(e) << " oppid=" << G.id(G.opposite(e))
1.122 - << " em=" << em[e]
1.123 - << " sm=" << sm[e] << "\n";
1.124 -
1.125 - }
1.126 -
1.127 -}