alpar@342: #include alpar@342: #include alpar@342: alpar@921: using namespace lemon; alpar@342: alpar@342: template alpar@342: class CinCoutMap alpar@342: { alpar@342: public: alpar@342: typedef GG Graph; alpar@342: typedef typename GG::Edge Edge; alpar@342: alpar@987: typedef Edge Key; alpar@987: typedef TT Value; alpar@342: alpar@342: class RefType alpar@342: { alpar@342: Graph &G; alpar@342: Edge e; alpar@342: public: alpar@342: RefType(Graph &_G,Edge _e) : G(_G), e(_e) { } alpar@342: alpar@987: operator Value() const alpar@342: { alpar@987: Value tmp; alpar@986: std::cout << G.id(G.source(e)) << "->" alpar@986: << G.id(G.target(e)) << ": "; alpar@342: std::cin >> tmp; alpar@342: return tmp; alpar@342: } alpar@987: Value operator = (Value v) const alpar@342: { alpar@986: std::cout << G.id(G.source(e)) << "->" alpar@986: << G.id(G.target(e)) << ": " << v << '\n'; alpar@342: return v; alpar@342: } alpar@342: }; alpar@342: alpar@342: private: alpar@342: Graph &G; alpar@342: public: alpar@342: CinCoutMap(Graph &_G) : G(_G) { } alpar@342: RefType operator[] (Edge e) const { return RefType(G,e);} alpar@342: }; alpar@342: alpar@351: template alpar@351: class NullMap alpar@351: { alpar@351: public: alpar@987: typedef K Key; alpar@987: typedef T Value; alpar@351: alpar@351: class RefType alpar@351: { alpar@987: Value val; alpar@351: public: alpar@987: RefType(Value v) : val(v) { } alpar@987: operator Value() const { return val; } alpar@987: Value operator = (Value v) const { return val; } alpar@351: }; alpar@351: alpar@351: private: alpar@987: Value val; alpar@351: public: alpar@987: NullMap(Value v) : val(v) { } alpar@987: RefType operator[] (Key e) const { return RefType(v);} alpar@351: }; alpar@351: alpar@342: int main() alpar@342: { alpar@342: typedef SmartGraph Graph; alpar@342: typedef Graph::NodeIt NodeIt; alpar@342: typedef Graph::OutEdgeIt OutEdgeIt; alpar@342: typedef Graph::EdgeIt EdgeIt; alpar@342: alpar@342: Graph G; alpar@342: alpar@342: CinCoutMap map(G); alpar@342: alpar@342: Graph::EdgeMap emap(G); alpar@342: alpar@342: for(int i=0;i<3;i++) G.addNode(); alpar@342: alpar@342: for(NodeIt n(G);G.valid(n);G.next(n)) alpar@342: for(NodeIt m(G);G.valid(m);G.next(m)) if(n!=m) alpar@342: G.addEdge(n,m); alpar@342: alpar@342: //for(OutEdgeIt e(G,NodeIt(G));G.valid(e);G.next(e)) alpar@342: alpar@342: for(EdgeIt e(G);G.valid(e);G.next(e)) emap[e] = map[e]; alpar@342: alpar@342: std::cout << '\n'; alpar@342: alpar@342: for(EdgeIt e(G);G.valid(e);G.next(e)) map[e] = emap[e]; alpar@342: alpar@342: } alpar@342: