Tulip  5.0.0
Large graphs analysis and drawing
IntegerProperty.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
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_INT_H
21 #define TULIP_INT_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/Observable.h>
28 #include <tulip/minmaxproperty.h>
29 #include <tulip/NumericProperty.h>
30 
31 namespace tlp {
32 
33 class Graph;
34 class PropertyContext;
35 
36 typedef MinMaxProperty<tlp::IntegerType, tlp::IntegerType, tlp::NumericProperty> IntegerMinMaxProperty;
37 
38 /**
39  * @ingroup Graph
40  * @brief A graph property that maps an integer value to graph elements.
41  */
42 class TLP_SCOPE IntegerProperty : public IntegerMinMaxProperty {
43 
44 public :
45  IntegerProperty(Graph *, const std::string& n = "");
46 
47  PropertyInterface* clonePrototype(Graph *, const std::string&) const;
48  static const std::string propertyTypename;
49  const std::string& getTypename() const {
50  return propertyTypename;
51  }
52  virtual void setNodeValue(const node n,
53  tlp::StoredType<int>::ReturnedConstValue v);
54  virtual void setEdgeValue(const edge e,
55  tlp::StoredType<int>::ReturnedConstValue v);
56  virtual void setAllNodeValue(tlp::StoredType<int>::ReturnedConstValue v);
57 
58  virtual void setValueToGraphNodes(tlp::StoredType<int>::ReturnedConstValue v, const Graph *graph);
59  virtual void setAllEdgeValue(tlp::StoredType<int>::ReturnedConstValue v);
60  virtual void setValueToGraphEdges(tlp::StoredType<int>::ReturnedConstValue v, const Graph *graph);
61 
62  int compare(const node n1, const node n2) const;
63  int compare(const edge e1, const edge e2) const;
64 
65  // NumericProperty interface
66  virtual double getNodeDoubleValue(const node n) const {
67  return (double) getNodeValue(n);
68  }
69  virtual double getNodeDoubleDefaultValue() const {
70  return (double) getNodeDefaultValue();
71  }
72  virtual double getNodeDoubleMin(const Graph* g = NULL) {
73  return (double) getNodeMin(g);
74  }
75  virtual double getNodeDoubleMax(const Graph* g = NULL) {
76  return (double) getNodeMax(g);
77  }
78  virtual double getEdgeDoubleValue(const edge e) const {
79  return (double) getEdgeValue(e);
80  }
81  virtual double getEdgeDoubleDefaultValue() const {
82  return (double) getEdgeDefaultValue();
83  }
84  virtual double getEdgeDoubleMin(const Graph* g = NULL) {
85  return (double) getEdgeMin(g);
86  }
87  virtual double getEdgeDoubleMax(const Graph* g = NULL) {
88  return (double) getEdgeMax(g);
89  }
90 
91  void nodesUniformQuantification(unsigned int);
92 
93  void edgesUniformQuantification(unsigned int);
94 
95  NumericProperty* copyProperty(Graph *g) {
96  IntegerProperty* newProp = new IntegerProperty(g);
97  newProp->copy(this);
98 
99  return newProp;
100  }
101 
102  _DEPRECATED virtual void setAllNodeValue(tlp::StoredType<int>::ReturnedConstValue v, const Graph *graph);
103  _DEPRECATED virtual void setAllEdgeValue(tlp::StoredType<int>::ReturnedConstValue v, const Graph *graph);
104 
105 protected:
107 
108 private:
109  // override Observable::treatEvent
110  void treatEvent(const Event&);
111 };
112 
113 /**
114  * @ingroup Graph
115  * @brief A graph property that maps a std::vector<int> value to graph elements.
116  */
117 class TLP_SCOPE IntegerVectorProperty:public AbstractVectorProperty<tlp::IntegerVectorType, tlp::IntegerType> {
118 public :
119  IntegerVectorProperty(Graph *g, const std::string& n =""):AbstractVectorProperty<IntegerVectorType, tlp::IntegerType>(g, n) {}
120  // redefinition of some PropertyInterface methods
121  PropertyInterface* clonePrototype(Graph *, const std::string&) const;
122  static const std::string propertyTypename;
123  const std::string& getTypename() const {
124  return propertyTypename;
125  }
126 
127 };
128 
129 
130 }
131 #endif
132 ///@endcond
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 std::vector<int> 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.
A graph property that maps an integer value to graph elements.