A generic map with value type [0, N) where N is a small integer.
Can enumerate keys with a given value.
2 #include <smart_graph.h>
6 template<class GG,class TT>
11 typedef typename GG::Edge Edge;
21 RefType(Graph &_G,Edge _e) : G(_G), e(_e) { }
23 operator ValueType() const
26 std::cout << G.id(G.tail(e)) << "->"
27 << G.id(G.head(e)) << ": ";
31 ValueType operator = (ValueType v) const
33 std::cout << G.id(G.tail(e)) << "->"
34 << G.id(G.head(e)) << ": " << v << '\n';
42 CinCoutMap(Graph &_G) : G(_G) { }
43 RefType operator[] (Edge e) const { return RefType(G,e);}
48 typedef SmartGraph Graph;
49 typedef Graph::NodeIt NodeIt;
50 typedef Graph::OutEdgeIt OutEdgeIt;
51 typedef Graph::EdgeIt EdgeIt;
55 CinCoutMap<Graph,int> map(G);
57 Graph::EdgeMap<int> emap(G);
59 for(int i=0;i<3;i++) G.addNode();
61 for(NodeIt n(G);G.valid(n);G.next(n))
62 for(NodeIt m(G);G.valid(m);G.next(m)) if(n!=m)
65 //for(OutEdgeIt e(G,NodeIt(G));G.valid(e);G.next(e))
67 for(EdgeIt e(G);G.valid(e);G.next(e)) emap[e] = map[e];
71 for(EdgeIt e(G);G.valid(e);G.next(e)) map[e] = emap[e];