[6] | 1 | #include <mapstorage.h> |
---|
| 2 | |
---|
| 3 | MapStorage::MapStorage(Graph & graph):g(graph) |
---|
| 4 | { |
---|
| 5 | }; |
---|
| 6 | |
---|
| 7 | int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap) |
---|
| 8 | { |
---|
[46] | 9 | if( nodemap_storage.find(name) == nodemap_storage.end() ) |
---|
| 10 | { |
---|
| 11 | nodemap_storage[name]=nodemap; |
---|
| 12 | return 0; |
---|
| 13 | } |
---|
| 14 | return 1; |
---|
[6] | 15 | } |
---|
| 16 | |
---|
| 17 | int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap) |
---|
| 18 | { |
---|
[46] | 19 | if( edgemap_storage.find(name) == edgemap_storage.end() ) |
---|
| 20 | { |
---|
| 21 | edgemap_storage[name]=edgemap; |
---|
| 22 | return 0; |
---|
| 23 | } |
---|
| 24 | return 1; |
---|
[6] | 25 | } |
---|
| 26 | |
---|
| 27 | double MapStorage::maxOfNodeMap(const std::string & name) |
---|
| 28 | { |
---|
| 29 | double max=0; |
---|
| 30 | for (NodeIt j(g); j!=INVALID; ++j) |
---|
| 31 | { |
---|
| 32 | if( (*nodemap_storage[name])[j]>max ) |
---|
| 33 | { |
---|
| 34 | max=(*nodemap_storage[name])[j]; |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | return max; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | double MapStorage::maxOfEdgeMap(const std::string & name) |
---|
| 41 | { |
---|
| 42 | double max=0; |
---|
| 43 | for (EdgeIt j(g); j!=INVALID; ++j) |
---|
| 44 | { |
---|
| 45 | if( (*edgemap_storage[name])[j]>max ) |
---|
| 46 | { |
---|
| 47 | max=(*edgemap_storage[name])[j]; |
---|
| 48 | } |
---|
| 49 | } |
---|
| 50 | return max; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | double MapStorage::minOfNodeMap(const std::string & name) |
---|
| 54 | { |
---|
| 55 | NodeIt j(g); |
---|
| 56 | double min=(*nodemap_storage[name])[j]; |
---|
| 57 | for (; j!=INVALID; ++j) |
---|
| 58 | { |
---|
| 59 | if( (*nodemap_storage[name])[j]<min ) |
---|
| 60 | { |
---|
| 61 | min=(*nodemap_storage[name])[j]; |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | return min; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | double MapStorage::minOfEdgeMap(const std::string & name) |
---|
| 68 | { |
---|
| 69 | EdgeIt j(g); |
---|
| 70 | double min=(*edgemap_storage[name])[j]; |
---|
| 71 | for (EdgeIt j(g); j!=INVALID; ++j) |
---|
| 72 | { |
---|
| 73 | if( (*edgemap_storage[name])[j]<min ) |
---|
| 74 | { |
---|
| 75 | min=(*edgemap_storage[name])[j]; |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | return min; |
---|
| 79 | } |
---|
| 80 | |
---|
[30] | 81 | void MapStorage::initMapsForEdge(Graph::Edge e) |
---|
[26] | 82 | { |
---|
[31] | 83 | std::map< std::string,Graph::EdgeMap<double> * >::iterator ems_it; |
---|
| 84 | for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++) |
---|
| 85 | { |
---|
| 86 | (*((*ems_it).second))[e]=5; |
---|
| 87 | } |
---|
[26] | 88 | } |
---|