COIN-OR::LEMON - Graph Library

source: glemon-0.x/mapstorage.cc @ 38:9cab23d9b124

gui
Last change on this file since 38:9cab23d9b124 was 31:66e85f44a66f, checked in by Hegyi Péter, 15 years ago

Uh, long comment arrives... Zoom update does not happen after editorial steps. Nodes initial color is light blue, if there is any item under them. Strange node-text relations disappeared. Initial values of new items are given now in a more common way. The wood-cutter way of handling default values of properties is now changed.

File size: 1.6 KB
Line 
1#include <mapstorage.h>
2
3MapStorage::MapStorage(Graph & graph):g(graph)
4{
5};
6
7int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap)
8{
9  nodemap_storage[name]=nodemap;
10  return 0;
11}
12
13int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap)
14{
15  edgemap_storage[name]=edgemap;
16  return 0;
17}
18
19double MapStorage::maxOfNodeMap(const std::string & name)
20{
21  double max=0;
22  for (NodeIt j(g); j!=INVALID; ++j)
23  {
24    if( (*nodemap_storage[name])[j]>max )
25    {
26      max=(*nodemap_storage[name])[j];
27    }
28  }
29  return max;
30}
31
32double MapStorage::maxOfEdgeMap(const std::string & name)
33{
34  double max=0;
35  for (EdgeIt j(g); j!=INVALID; ++j)
36  {
37    if( (*edgemap_storage[name])[j]>max )
38    {
39      max=(*edgemap_storage[name])[j];
40    }
41  }
42  return max;
43}
44
45double MapStorage::minOfNodeMap(const std::string & name)
46{
47  NodeIt j(g);
48  double min=(*nodemap_storage[name])[j];
49  for (; j!=INVALID; ++j)
50  {
51    if( (*nodemap_storage[name])[j]<min )
52    {
53      min=(*nodemap_storage[name])[j];
54    }
55  }
56  return min;
57}
58
59double MapStorage::minOfEdgeMap(const std::string & name)
60{
61  EdgeIt j(g);
62  double min=(*edgemap_storage[name])[j];
63  for (EdgeIt j(g); j!=INVALID; ++j)
64  {
65    if( (*edgemap_storage[name])[j]<min )
66    {
67      min=(*edgemap_storage[name])[j];
68    }
69  }
70  return min;
71}
72
73void MapStorage::initMapsForEdge(Graph::Edge e)
74{
75  std::map< std::string,Graph::EdgeMap<double> * >::iterator ems_it;
76  for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++)
77    {
78      (*((*ems_it).second))[e]=5;
79    }
80}
Note: See TracBrowser for help on using the repository browser.