deba@1267: #include deba@1267: #include deba@1267: #include deba@1267: #include deba@1267: #include deba@1267: #include deba@1267: #include deba@1267: #include deba@1267: deba@1267: using namespace std; deba@1267: using namespace lemon; deba@1267: deba@1267: template deba@1267: struct unary_compose { deba@1267: typedef typename G::argument_type argument_type; deba@1267: typedef typename F::result_type result_type; deba@1267: deba@1267: unary_compose(const F& _f, const G& _g) : f(_f), g(_g) {} deba@1267: deba@1267: result_type operator()(const argument_type& x) { deba@1267: return f(g(x)); deba@1267: } deba@1267: deba@1267: private: deba@1267: F f; deba@1267: G g; deba@1267: }; deba@1267: deba@1267: template deba@1267: unary_compose compose1(const F& f, const G& g) { deba@1267: return unary_compose(f, g); deba@1267: } deba@1267: deba@1267: deba@1267: deba@1267: deba@1267: template deba@1267: struct Second { deba@1267: typedef T argument_type; deba@1267: typedef typename T::second_type result_type; deba@1267: deba@1267: typename T::second_type operator()(const T& t) const { deba@1267: return t.second; deba@1267: } deba@1267: }; deba@1267: deba@1267: template deba@1267: struct First { deba@1267: typedef T argument_type; deba@1267: typedef typename T::first_type result_type; deba@1267: typename T::first_type operator()(const T& t) const { deba@1267: return t.first; deba@1267: } deba@1267: }; deba@1267: deba@1267: deba@1267: int main() { deba@1267: deba@1267: typedef ListGraph Graph; deba@1267: deba@1267: typedef Graph::Edge Edge; deba@1267: typedef Graph::Node Node; deba@1267: typedef Graph::EdgeIt EdgeIt; deba@1267: typedef Graph::NodeIt NodeIt; deba@1267: typedef Graph::EdgeMap LengthMap; deba@1267: deba@1267: typedef IdMap EdgeIdMap; deba@1267: deba@1267: Graph graph; deba@1267: LengthMap length(graph); deba@1267: deba@1267: readGraph(std::cin, graph, length); deba@1267: deba@1267: const LengthMap& constLength = length; deba@1267: deba@1267: copy(length.valueSet().begin(), length.valueSet().end(), deba@1267: ostream_iterator(cout, " ")); deba@1267: cout << endl; deba@1267: deba@1267: deba@1267: copy(constLength.valueSet().begin(), constLength.valueSet().end(), deba@1267: ostream_iterator(cout, " ")); deba@1267: cout << endl; deba@1267: deba@1267: deba@1267: transform(constLength.keySet().begin(), constLength.keySet().end(), deba@1267: ostream_iterator(cout, " "), deba@1267: MapFunctor(EdgeIdMap(graph))); deba@1267: cout << endl; deba@1267: deba@1267: deba@1267: transform(constLength.mapSet().begin(), constLength.mapSet().end(), deba@1267: ostream_iterator(cout, " "), deba@1267: Second()); deba@1267: cout << endl; deba@1267: deba@1267: transform(constLength.mapSet().begin(), constLength.mapSet().end(), deba@1267: ostream_iterator(cout, " "), deba@1267: compose1(MapFunctor(EdgeIdMap(graph)), deba@1267: First() )); deba@1267: cout << endl; deba@1267: deba@1267: transform(length.mapSet().begin(), length.mapSet().end(), deba@1267: ostream_iterator(cout, " "), deba@1267: Second()); deba@1267: cout << endl; deba@1267: deba@1267: transform(length.mapSet().begin(), length.mapSet().end(), deba@1267: ostream_iterator(cout, " "), deba@1267: compose1(MapFunctor(EdgeIdMap(graph)), deba@1267: First() )); deba@1267: cout << endl; deba@1267: deba@1267: return 0; deba@1267: }