mapstorage.cc
author hegyi
Wed, 29 Jun 2005 15:41:33 +0000
branchgui
changeset 30 f70bbee5350a
parent 28 fa28f1071bd6
child 31 66e85f44a66f
permissions -rw-r--r--
Function names are corrected according to naming conventions.
     1 #include <mapstorage.h>
     2 
     3 MapStorage::MapStorage(Graph & graph):g(graph)
     4 {
     5   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
     6   {
     7     Graph::EdgeMap<double> emd(g,edge_property_defaults[i]);
     8     default_edgemaps.push_back(emd);
     9   }
    10 
    11   for(int i=0;i<NODE_PROPERTY_NUM;i++)
    12   {
    13     Graph::NodeMap<double> nmd(g,node_property_defaults[i]);
    14     default_nodemaps.push_back(nmd);
    15   }
    16 
    17   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    18   {
    19       for (EdgeIt j(g); j!=INVALID; ++j)
    20       {
    21 	(default_edgemaps[i])[j]=edge_property_defaults[i];
    22       }
    23       addEdgeMap(edge_property_strings[i],&(default_edgemaps[i]));
    24   }
    25 
    26   for(int i=0;i<NODE_PROPERTY_NUM;i++)
    27   {
    28       for (NodeIt j(g); j!=INVALID; ++j)
    29       {
    30 	(default_nodemaps[i])[j]=node_property_defaults[i];
    31       }
    32       addNodeMap(node_property_strings[i],&(default_nodemaps[i]));
    33   }
    34 
    35 };
    36 
    37 int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap)
    38 {
    39   nodemap_storage[name]=nodemap;
    40   return 0;
    41 }
    42 
    43 int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap)
    44 {
    45   edgemap_storage[name]=edgemap;
    46   return 0;
    47 }
    48 
    49 double MapStorage::maxOfNodeMap(const std::string & name)
    50 {
    51   double max=0;
    52   for (NodeIt j(g); j!=INVALID; ++j)
    53   {
    54     if( (*nodemap_storage[name])[j]>max )
    55     {
    56       max=(*nodemap_storage[name])[j];
    57     }
    58   }
    59   return max;
    60 }
    61 
    62 double MapStorage::maxOfEdgeMap(const std::string & name)
    63 {
    64   double max=0;
    65   for (EdgeIt j(g); j!=INVALID; ++j)
    66   {
    67     if( (*edgemap_storage[name])[j]>max )
    68     {
    69       max=(*edgemap_storage[name])[j];
    70     }
    71   }
    72   return max;
    73 }
    74 
    75 double MapStorage::minOfNodeMap(const std::string & name)
    76 {
    77   NodeIt j(g);
    78   double min=(*nodemap_storage[name])[j];
    79   for (; j!=INVALID; ++j)
    80   {
    81     if( (*nodemap_storage[name])[j]<min )
    82     {
    83       min=(*nodemap_storage[name])[j];
    84     }
    85   }
    86   return min;
    87 }
    88 
    89 double MapStorage::minOfEdgeMap(const std::string & name)
    90 {
    91   EdgeIt j(g);
    92   double min=(*edgemap_storage[name])[j];
    93   for (EdgeIt j(g); j!=INVALID; ++j)
    94   {
    95     if( (*edgemap_storage[name])[j]<min )
    96     {
    97       min=(*edgemap_storage[name])[j];
    98     }
    99   }
   100   return min;
   101 }
   102 
   103 void MapStorage::initMapsForEdge(Graph::Edge e)
   104 {
   105   e=e;
   106 // beragad, aztan csovez
   107 //   std::map< std::string,Graph::EdgeMap<double> * >::iterator ems_it;
   108 //   for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++)
   109 //     {
   110 //       std::cout << "szevasz\n";
   111 //       (*((*ems_it).second))[e]=0;
   112 //     }
   113 //   std::cout << std::endl;
   114 
   115 // g_closure_invoke...
   116 //   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   117 //     {
   118 //       (default_edgemaps[i])[e]=property_defaults[i];
   119 //     }
   120 }