A year has passed again.
1 #include <lemon/list_graph.h>
2 #include <lemon/maps.h>
13 typedef typename Graph::Node Node;
14 typedef typename Graph::Edge Edge;
16 ///A beolvasando ertekek tipusa.
18 ///Ebben gyakorlatilag egy stringet tarolunk.
19 ///Tovabba ez egy olyan tipus, amitol elvarjuk, hogy konvertalodjon
20 ///a beolvasando mapok Value-jara.
24 operator int() const { return 0; }
25 operator double() const { return 0; }
28 ///Ez adja a mapok kozos interface-et.
32 virtual void set(Edge n,const InputValue &v) = 0;
33 virtual ~WrapEdgeMapBase() {}
36 ///Ez meg becsomagol egy mapot a kozos formara.
38 class WrapEdgeMap : public WrapEdgeMapBase
43 WrapEdgeMap(M &m) : map(m) {}
44 void set(Edge n,const InputValue &v) {map.set(n,v);}
47 ///Ebben a strukturaban adunk meg egy feltoltendo mapot.
54 template<class M> EdgeMapDesc(char *n,M &m) : name(n), map(&m) {}
58 ///Itt vannak felsorolva a feltoltendo mapok
59 std::list<EdgeMapDesc> EdgeMaps;
61 ///Ezzel lehet egy mapot hozzaadni a feltoltendok listajahoz.
62 template<class M> void addEdgeMap(char *name,M &map)
64 EdgeMaps.push_back(EdgeMapDesc(name,*(new WrapEdgeMap<M>(map))));
67 ///Ez meg kiuriti a map-listat.
70 while(EdgeMaps.begin()!=EdgeMaps.end()) {
72 delete EdgeMaps.begin()->map;
77 //Esetleg stream a file-nev helyett...
78 Reader(char *file,Graph &G)
83 ///Ez inditja a beolvasast.
86 //Ez olvassa be/vegig a file-t.
97 class SumMap : public MapBase<ListGraph::Edge,double>
102 void set(ListGraph::Edge e,double d)
106 double getSum() { return sum; }
111 ListGraph g; //Kis g!!!
112 ListGraph::EdgeMap<double> cost(g);
113 ListGraph::EdgeMap<int> channels(g);
115 SumMap sum_cost; //Ez egy sajat "custom" irhato map
117 Reader<ListGraph> r("file_name.lgf",g);
118 r.addEdgeMap("cost",cost);
119 r.addEdgeMap("channels",channels);
120 r.addEdgeMap("cost",sum_cost);