COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/mapstorage.cc @ 1505:7121597da9ba

Last change on this file since 1505:7121597da9ba was 1442:1e3c69aa035b, checked in by Akos Ladanyi, 16 years ago

dos2unix

File size: 1.7 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
Note: See TracBrowser for help on using the repository browser.