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@342: typedef Edge KeyType; alpar@342: typedef TT ValueType; 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@342: operator ValueType() const alpar@342: { alpar@342: ValueType tmp; alpar@342: std::cout << G.id(G.tail(e)) << "->" alpar@342: << G.id(G.head(e)) << ": "; alpar@342: std::cin >> tmp; alpar@342: return tmp; alpar@342: } alpar@342: ValueType operator = (ValueType v) const alpar@342: { alpar@342: std::cout << G.id(G.tail(e)) << "->" alpar@342: << G.id(G.head(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@351: typedef K KeyType; alpar@351: typedef T ValueType; alpar@351: alpar@351: class RefType alpar@351: { alpar@351: ValueType val; alpar@351: public: alpar@351: RefType(ValueType v) : val(v) { } alpar@351: operator ValueType() const { return val; } alpar@351: ValueType operator = (ValueType v) const { return val; } alpar@351: }; alpar@351: alpar@351: private: alpar@351: ValueType val; alpar@351: public: alpar@351: NullMap(ValueType v) : val(v) { } alpar@351: RefType operator[] (KeyType 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: