COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/mapstorage.cc @ 1509:f9113440b667

Last change on this file since 1509:f9113440b667 was 1509:f9113440b667, checked in by Hegyi Péter, 15 years ago

A bug, explored by Alpar is corrected, but with value-checking, and not with correct values. (There is some problem with map values of new items! Maybe refreshemnt is the responsible thing?)

File size: 2.2 KB
Line 
1#include <mapstorage.h>
2
3MapStorage::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
23int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap)
24{
25  nodemap_storage[name]=nodemap;
26  return 0;
27}
28
29int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap)
30{
31  edgemap_storage[name]=edgemap;
32  return 0;
33}
34
35double 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
48double 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
61double 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
75double 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
89void 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}
Note: See TracBrowser for help on using the repository browser.