Bug fixes.
5 #include <lemon/list_graph.h>
6 #include <lemon/map_iterator.h>
7 #include <lemon/graph_reader.h>
8 #include <lemon/maps.h>
11 using namespace lemon;
13 template <typename F, typename G>
14 struct unary_compose {
15 typedef typename G::argument_type argument_type;
16 typedef typename F::result_type result_type;
18 unary_compose(const F& _f, const G& _g) : f(_f), g(_g) {}
20 result_type operator()(const argument_type& x) {
29 template <typename F, typename G>
30 unary_compose<F, G> compose1(const F& f, const G& g) {
31 return unary_compose<F, G>(f, g);
39 typedef T argument_type;
40 typedef typename T::second_type result_type;
42 typename T::second_type operator()(const T& t) const {
49 typedef T argument_type;
50 typedef typename T::first_type result_type;
51 typename T::first_type operator()(const T& t) const {
59 typedef ListGraph Graph;
61 typedef Graph::Edge Edge;
62 typedef Graph::Node Node;
63 typedef Graph::EdgeIt EdgeIt;
64 typedef Graph::NodeIt NodeIt;
65 typedef Graph::EdgeMap<int> LengthMap;
67 typedef IdMap<Graph, Edge> EdgeIdMap;
70 LengthMap length(graph);
72 readGraph(std::cin, graph, length);
74 const LengthMap& constLength = length;
76 copy(length.valueSet().begin(), length.valueSet().end(),
77 ostream_iterator<int>(cout, " "));
81 copy(constLength.valueSet().begin(), constLength.valueSet().end(),
82 ostream_iterator<int>(cout, " "));
86 transform(constLength.keySet().begin(), constLength.keySet().end(),
87 ostream_iterator<int>(cout, " "),
88 MapFunctor<EdgeIdMap>(EdgeIdMap(graph)));
92 transform(constLength.mapSet().begin(), constLength.mapSet().end(),
93 ostream_iterator<int>(cout, " "),
94 Second<LengthMap::MapSet::Value>());
97 transform(constLength.mapSet().begin(), constLength.mapSet().end(),
98 ostream_iterator<int>(cout, " "),
99 compose1(MapFunctor<EdgeIdMap>(EdgeIdMap(graph)),
100 First<LengthMap::MapSet::Value>() ));
103 transform(length.mapSet().begin(), length.mapSet().end(),
104 ostream_iterator<int>(cout, " "),
105 Second<LengthMap::MapSet::Value>());
108 transform(length.mapSet().begin(), length.mapSet().end(),
109 ostream_iterator<int>(cout, " "),
110 compose1(MapFunctor<EdgeIdMap>(EdgeIdMap(graph)),
111 First<LengthMap::MapSet::Value>() ));