1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/work/alpar/rw_nonref_map.cc Fri Apr 16 21:18:40 2004 +0000
1.3 @@ -0,0 +1,74 @@
1.4 +#include <iostream>
1.5 +#include <smart_graph.h>
1.6 +
1.7 +using namespace hugo;
1.8 +
1.9 +template<class GG,class TT>
1.10 +class CinCoutMap
1.11 +{
1.12 +public:
1.13 + typedef GG Graph;
1.14 + typedef typename GG::Edge Edge;
1.15 +
1.16 + typedef Edge KeyType;
1.17 + typedef TT ValueType;
1.18 +
1.19 + class RefType
1.20 + {
1.21 + Graph &G;
1.22 + Edge e;
1.23 + public:
1.24 + RefType(Graph &_G,Edge _e) : G(_G), e(_e) { }
1.25 +
1.26 + operator ValueType() const
1.27 + {
1.28 + ValueType tmp;
1.29 + std::cout << G.id(G.tail(e)) << "->"
1.30 + << G.id(G.head(e)) << ": ";
1.31 + std::cin >> tmp;
1.32 + return tmp;
1.33 + }
1.34 + ValueType operator = (ValueType v) const
1.35 + {
1.36 + std::cout << G.id(G.tail(e)) << "->"
1.37 + << G.id(G.head(e)) << ": " << v << '\n';
1.38 + return v;
1.39 + }
1.40 + };
1.41 +
1.42 +private:
1.43 + Graph &G;
1.44 +public:
1.45 + CinCoutMap(Graph &_G) : G(_G) { }
1.46 + RefType operator[] (Edge e) const { return RefType(G,e);}
1.47 +};
1.48 +
1.49 +int main()
1.50 +{
1.51 + typedef SmartGraph Graph;
1.52 + typedef Graph::NodeIt NodeIt;
1.53 + typedef Graph::OutEdgeIt OutEdgeIt;
1.54 + typedef Graph::EdgeIt EdgeIt;
1.55 +
1.56 + Graph G;
1.57 +
1.58 + CinCoutMap<Graph,int> map(G);
1.59 +
1.60 + Graph::EdgeMap<int> emap(G);
1.61 +
1.62 + for(int i=0;i<3;i++) G.addNode();
1.63 +
1.64 + for(NodeIt n(G);G.valid(n);G.next(n))
1.65 + for(NodeIt m(G);G.valid(m);G.next(m)) if(n!=m)
1.66 + G.addEdge(n,m);
1.67 +
1.68 + //for(OutEdgeIt e(G,NodeIt(G));G.valid(e);G.next(e))
1.69 +
1.70 + for(EdgeIt e(G);G.valid(e);G.next(e)) emap[e] = map[e];
1.71 +
1.72 + std::cout << '\n';
1.73 +
1.74 + for(EdgeIt e(G);G.valid(e);G.next(e)) map[e] = emap[e];
1.75 +
1.76 +}
1.77 +