1 | #include <mapstorage.h> |
---|
2 | |
---|
3 | MapStorage::MapStorage(Graph & graph):g(graph) |
---|
4 | { |
---|
5 | for(int i=0;i<PROPERTY_NUM;i++) |
---|
6 | { |
---|
7 | Graph::EdgeMap<double> emd(g); |
---|
8 | default_edgemaps.push_back(emd); |
---|
9 | Graph::NodeMap<double> nmd(g); |
---|
10 | default_nodemaps.push_back(nmd); |
---|
11 | } |
---|
12 | for(int i=0;i<PROPERTY_NUM;i++) |
---|
13 | { |
---|
14 | for (EdgeIt j(g); j!=INVALID; ++j) |
---|
15 | { |
---|
16 | (default_edgemaps[i])[j]=property_defaults[i]; |
---|
17 | } |
---|
18 | addEdgeMap(property_strings[i],&(default_edgemaps[i])); |
---|
19 | } |
---|
20 | |
---|
21 | }; |
---|
22 | |
---|
23 | int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap) |
---|
24 | { |
---|
25 | nodemap_storage[name]=nodemap; |
---|
26 | return 0; |
---|
27 | } |
---|
28 | |
---|
29 | int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap) |
---|
30 | { |
---|
31 | edgemap_storage[name]=edgemap; |
---|
32 | return 0; |
---|
33 | } |
---|
34 | |
---|
35 | double MapStorage::maxOfNodeMap(const std::string & name) |
---|
36 | { |
---|
37 | double max=0; |
---|
38 | for (NodeIt j(g); j!=INVALID; ++j) |
---|
39 | { |
---|
40 | if( (*nodemap_storage[name])[j]>max ) |
---|
41 | { |
---|
42 | max=(*nodemap_storage[name])[j]; |
---|
43 | } |
---|
44 | } |
---|
45 | return max; |
---|
46 | } |
---|
47 | |
---|
48 | double MapStorage::maxOfEdgeMap(const std::string & name) |
---|
49 | { |
---|
50 | double max=0; |
---|
51 | for (EdgeIt j(g); j!=INVALID; ++j) |
---|
52 | { |
---|
53 | if( (*edgemap_storage[name])[j]>max ) |
---|
54 | { |
---|
55 | max=(*edgemap_storage[name])[j]; |
---|
56 | } |
---|
57 | } |
---|
58 | return max; |
---|
59 | } |
---|
60 | |
---|
61 | double MapStorage::minOfNodeMap(const std::string & name) |
---|
62 | { |
---|
63 | NodeIt j(g); |
---|
64 | double min=(*nodemap_storage[name])[j]; |
---|
65 | for (; j!=INVALID; ++j) |
---|
66 | { |
---|
67 | if( (*nodemap_storage[name])[j]<min ) |
---|
68 | { |
---|
69 | min=(*nodemap_storage[name])[j]; |
---|
70 | } |
---|
71 | } |
---|
72 | return min; |
---|
73 | } |
---|
74 | |
---|
75 | double MapStorage::minOfEdgeMap(const std::string & name) |
---|
76 | { |
---|
77 | EdgeIt j(g); |
---|
78 | double min=(*edgemap_storage[name])[j]; |
---|
79 | for (EdgeIt j(g); j!=INVALID; ++j) |
---|
80 | { |
---|
81 | if( (*edgemap_storage[name])[j]<min ) |
---|
82 | { |
---|
83 | min=(*edgemap_storage[name])[j]; |
---|
84 | } |
---|
85 | } |
---|
86 | return min; |
---|
87 | } |
---|
88 | |
---|
89 | void MapStorage::init_maps_for_edge(Graph::Edge e) |
---|
90 | { |
---|
91 | e=e; |
---|
92 | // beragad, aztan csovez |
---|
93 | // std::map< std::string,Graph::EdgeMap<double> * >::iterator ems_it; |
---|
94 | // for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++) |
---|
95 | // { |
---|
96 | // std::cout << "szevasz\n"; |
---|
97 | // (*((*ems_it).second))[e]=0; |
---|
98 | // } |
---|
99 | // std::cout << std::endl; |
---|
100 | |
---|
101 | // g_closure_invoke... |
---|
102 | // for(int i=0;i<PROPERTY_NUM;i++) |
---|
103 | // { |
---|
104 | // (default_edgemaps[i])[e]=property_defaults[i]; |
---|
105 | // } |
---|
106 | } |
---|