COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/gui/mapstorage.cc @ 1413:3f45d58969d4

Last change on this file since 1413:3f45d58969d4 was 1412:c7fab5a1174a, checked in by Akos Ladanyi, 20 years ago

moved the gui

File size: 1.8 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
13  //std::string defaultstr="Default ";
14  for(int i=0;i<PROPERTY_NUM;i++)
15  {
16      for (EdgeIt j(g); j!=INVALID; ++j)
17      {
18        (default_edgemaps[i])[j]=property_defaults[i];
19      }
20      addEdgeMap(property_strings[i],&(default_edgemaps[i]));
21  }
22
23};
24
25int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap)
26{
27  nodemap_storage[name]=nodemap;
28  return 0;
29}
30int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap)
31{
32  edgemap_storage[name]=edgemap;
33  return 0;
34}
35
36double MapStorage::maxOfNodeMap(const std::string & name)
37{
38  double max=0;
39  for (NodeIt j(g); j!=INVALID; ++j)
40  {
41    if( (*nodemap_storage[name])[j]>max )
42    {
43      max=(*nodemap_storage[name])[j];
44    }
45  }
46  return max;
47}
48
49double MapStorage::maxOfEdgeMap(const std::string & name)
50{
51  double max=0;
52  for (EdgeIt j(g); j!=INVALID; ++j)
53  {
54    if( (*edgemap_storage[name])[j]>max )
55    {
56      max=(*edgemap_storage[name])[j];
57    }
58  }
59  return max;
60}
61
62double MapStorage::minOfNodeMap(const std::string & name)
63{
64  NodeIt j(g);
65  double min=(*nodemap_storage[name])[j];
66  for (; j!=INVALID; ++j)
67  {
68    if( (*nodemap_storage[name])[j]<min )
69    {
70      min=(*nodemap_storage[name])[j];
71    }
72  }
73  return min;
74}
75
76double MapStorage::minOfEdgeMap(const std::string & name)
77{
78  EdgeIt j(g);
79  double min=(*edgemap_storage[name])[j];
80  for (EdgeIt j(g); j!=INVALID; ++j)
81  {
82    if( (*edgemap_storage[name])[j]<min )
83    {
84      min=(*edgemap_storage[name])[j];
85    }
86  }
87  return min;
88}
89
Note: See TracBrowser for help on using the repository browser.