Tulip  5.1.0
Large graphs analysis and drawing
DoubleProperty.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 #ifndef TULIP_METRIC_H
21 #define TULIP_METRIC_H
22 
23 #include <tulip/tuliphash.h>
24 #include <tulip/PropertyTypes.h>
25 #include <tulip/AbstractProperty.h>
26 #include <tulip/PropertyAlgorithm.h>
27 #include <tulip/minmaxproperty.h>
28 #include <tulip/NumericProperty.h>
29 
30 namespace tlp {
31 
32 class PropertyContext;
33 
34 typedef MinMaxProperty<tlp::DoubleType, tlp::DoubleType, tlp::NumericProperty> DoubleMinMaxProperty;
35 
36 /**
37  * @ingroup Graph
38  * @brief A graph property that maps a double value to graph elements.
39  */
40 class TLP_SCOPE DoubleProperty : public DoubleMinMaxProperty {
41 public :
42  DoubleProperty (Graph *, const std::string& n="");
43 
45 
46  PropertyInterface* clonePrototype(Graph *, const std::string&) const;
47  static const std::string propertyTypename;
48  const std::string& getTypename() const {
49  return propertyTypename;
50  }
51 
52  virtual void setNodeValue(const node n,
53  tlp::StoredType<double>::ReturnedConstValue v);
54  virtual void setEdgeValue(const edge e,
55  tlp::StoredType<double>::ReturnedConstValue v);
56  virtual void setAllNodeValue(tlp::StoredType<double>::ReturnedConstValue v);
57 
58  virtual void setValueToGraphNodes(tlp::StoredType<double>::ReturnedConstValue v, const Graph* graph);
59  virtual void setAllEdgeValue(tlp::StoredType<double>::ReturnedConstValue v);
60  virtual void setValueToGraphEdges(tlp::StoredType<double>::ReturnedConstValue v, const Graph *graph);
61 
62  enum PredefinedMetaValueCalculator {NO_CALC = 0, AVG_CALC = 1, SUM_CALC = 2,
63  MAX_CALC = 3, MIN_CALC = 4
64  };
65 
66  // setMetaValueCalculator overloading
67  virtual void setMetaValueCalculator(PropertyInterface::MetaValueCalculator* calc);
68  void setMetaValueCalculator(PredefinedMetaValueCalculator nodeCalc = AVG_CALC,
69  PredefinedMetaValueCalculator edgeCalc = AVG_CALC);
70 
71  // NumericProperty interface
72  virtual double getNodeDoubleValue(const node n) const {
73  return getNodeValue(n);
74  }
75  virtual double getNodeDoubleDefaultValue() const {
76  return getNodeDefaultValue();
77  }
78  virtual double getNodeDoubleMin(const Graph* g = NULL) {
79  return getNodeMin(g);
80  }
81  virtual double getNodeDoubleMax(const Graph* g = NULL) {
82  return getNodeMax(g);
83  }
84  virtual double getEdgeDoubleValue(const edge e) const {
85  return getEdgeValue(e);
86  }
87  virtual double getEdgeDoubleDefaultValue() const {
88  return getEdgeDefaultValue();
89  }
90  virtual double getEdgeDoubleMin(const Graph* g = NULL) {
91  return getEdgeMin(g);
92  }
93  virtual double getEdgeDoubleMax(const Graph* g = NULL) {
94  return getEdgeMax(g);
95  }
96 
97  void nodesUniformQuantification(unsigned int);
98 
99  void edgesUniformQuantification(unsigned int);
100 
101  NumericProperty* copyProperty(Graph *g) {
102  DoubleProperty* newProp = new DoubleProperty(g);
103  newProp->copy(this);
104 
105  return newProp;
106  }
107 
108  _DEPRECATED virtual void setAllEdgeValue(tlp::StoredType<double>::ReturnedConstValue v, const Graph *graph);
109  _DEPRECATED virtual void setAllNodeValue(tlp::StoredType<double>::ReturnedConstValue v, const Graph* graph);
110 
111 private:
112  // override Observable::treatEvent
113  void treatEvent(const Event&);
114 
115 };
116 
117 /**
118  * @ingroup Graph
119  * @brief A graph property that maps a std::vector<double> value to graph elements.
120  */
121 
122 class TLP_SCOPE DoubleVectorProperty:public AbstractVectorProperty<tlp::DoubleVectorType, tlp::DoubleType> {
123 public :
124  DoubleVectorProperty(Graph *g, const std::string& n=""):AbstractVectorProperty<DoubleVectorType, tlp::DoubleType>(g, n) {}
125  // redefinition of some PropertyInterface methods
126  PropertyInterface* clonePrototype(Graph *, const std::string&) const;
127  static const std::string propertyTypename;
128  const std::string& getTypename() const {
129  return propertyTypename;
130  }
131 
132 };
133 
134 
135 }
136 #endif
This class extends upon PropertyInterface, and adds type-safe methods to get and set the node and edg...
PropertyInterface describes the interface of a graph property.
The edge struct represents an edge in a Graph object.
Definition: Edge.h:39
The node struct represents a node in a Graph object.
Definition: Node.h:39
A graph property that maps a double value to graph elements.
Event is the base class for all events used in the Observation mechanism.
Definition: Observable.h:47
Interface all numerical properties. Property values are always returned as double.
Base class for computing values on meta nodes and edges.
A graph property that maps a std::vector<double> value to graph elements.