1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/mapstorage.cc Wed May 11 16:55:18 2005 +0000
1.3 @@ -0,0 +1,89 @@
1.4 +#include <mapstorage.h>
1.5 +
1.6 +MapStorage::MapStorage(Graph & graph):g(graph)
1.7 +{
1.8 + for(int i=0;i<PROPERTY_NUM;i++)
1.9 + {
1.10 + Graph::EdgeMap<double> emd(g);
1.11 + default_edgemaps.push_back(emd);
1.12 + Graph::NodeMap<double> nmd(g);
1.13 + default_nodemaps.push_back(nmd);
1.14 + }
1.15 +
1.16 + //std::string defaultstr="Default ";
1.17 + for(int i=0;i<PROPERTY_NUM;i++)
1.18 + {
1.19 + for (EdgeIt j(g); j!=INVALID; ++j)
1.20 + {
1.21 + (default_edgemaps[i])[j]=property_defaults[i];
1.22 + }
1.23 + addEdgeMap(property_strings[i],&(default_edgemaps[i]));
1.24 + }
1.25 +
1.26 +};
1.27 +
1.28 +int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap)
1.29 +{
1.30 + nodemap_storage[name]=nodemap;
1.31 + return 0;
1.32 +}
1.33 +int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap)
1.34 +{
1.35 + edgemap_storage[name]=edgemap;
1.36 + return 0;
1.37 +}
1.38 +
1.39 +double MapStorage::maxOfNodeMap(const std::string & name)
1.40 +{
1.41 + double max=0;
1.42 + for (NodeIt j(g); j!=INVALID; ++j)
1.43 + {
1.44 + if( (*nodemap_storage[name])[j]>max )
1.45 + {
1.46 + max=(*nodemap_storage[name])[j];
1.47 + }
1.48 + }
1.49 + return max;
1.50 +}
1.51 +
1.52 +double MapStorage::maxOfEdgeMap(const std::string & name)
1.53 +{
1.54 + double max=0;
1.55 + for (EdgeIt j(g); j!=INVALID; ++j)
1.56 + {
1.57 + if( (*edgemap_storage[name])[j]>max )
1.58 + {
1.59 + max=(*edgemap_storage[name])[j];
1.60 + }
1.61 + }
1.62 + return max;
1.63 +}
1.64 +
1.65 +double MapStorage::minOfNodeMap(const std::string & name)
1.66 +{
1.67 + NodeIt j(g);
1.68 + double min=(*nodemap_storage[name])[j];
1.69 + for (; j!=INVALID; ++j)
1.70 + {
1.71 + if( (*nodemap_storage[name])[j]<min )
1.72 + {
1.73 + min=(*nodemap_storage[name])[j];
1.74 + }
1.75 + }
1.76 + return min;
1.77 +}
1.78 +
1.79 +double MapStorage::minOfEdgeMap(const std::string & name)
1.80 +{
1.81 + EdgeIt j(g);
1.82 + double min=(*edgemap_storage[name])[j];
1.83 + for (EdgeIt j(g); j!=INVALID; ++j)
1.84 + {
1.85 + if( (*edgemap_storage[name])[j]<min )
1.86 + {
1.87 + min=(*edgemap_storage[name])[j];
1.88 + }
1.89 + }
1.90 + return min;
1.91 +}
1.92 +