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