Tulip  5.0.0
Large graphs analysis and drawing
NumericProperty.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 NUMERICPROPERTY_H
21 #define NUMERICPROPERTY_H
22 
23 #include <tulip/PropertyInterface.h>
24 
25 namespace tlp {
26 
27 /**
28  * @brief Interface all numerical properties.
29  * Property values are always returned as double
30  **/
31 class TLP_SCOPE NumericProperty : public PropertyInterface {
32 public:
33  /**
34  * @brief Returns the value associated with the node n in this property.
35  * @param n The node for which we want to get the value of the property.
36  **/
37  virtual double getNodeDoubleValue(const node n) const=0;
38 
39  /**
40  * @brief Gets the default node value of the property.
41  * @return The default value of nodes.
42  */
43  virtual double getNodeDoubleDefaultValue() const=0;
44 
45  /**
46  * @brief Gets the minimum value on the nodes.
47  * @param graph The graph on which to compute.
48  * @return The minimal value on this graph for this property.
49  **/
50  virtual double getNodeDoubleMin(const Graph* graph = NULL)=0;
51 
52  /**
53  * @brief Gets the maximum value on the nodes.
54  * @param graph The graph on which to compute.
55  * @return The maximal value on this graph for this property.
56  **/
57  virtual double getNodeDoubleMax(const Graph* graph = NULL)=0;
58 
59  /**
60  * @brief Returns the value associated with the edge e in this property.
61  * @param e The edge for which we want to get the value of the property.
62  **/
63  virtual double getEdgeDoubleValue(const edge e) const=0;
64 
65  /**
66  * @brief Gets the default edge value of the property.
67  * @return The default value of edges.
68  */
69  virtual double getEdgeDoubleDefaultValue() const=0;
70 
71  /**
72  * @brief Gets the minimum value on the edges.
73  * @param graph The graph on which to compute.
74  * @return The minimal value on this graph for this property.
75  **/
76  virtual double getEdgeDoubleMin(const Graph* graph = NULL)=0;
77 
78  /**
79  * @brief Gets the maximum value on the edges.
80  * @param graph The graph on which to compute.
81  * @return The maximal value on this graph for this property.
82  **/
83  virtual double getEdgeDoubleMax(const Graph* graph = NULL)=0;
84 
85  /**
86  * @brief computes a uniform quantification for the nodes
87  * associated values
88  */
89  virtual void nodesUniformQuantification(unsigned int)=0;
90 
91  /**
92  * @brief computes a uniform quantification for the edges
93  * associated values
94  */
95  virtual void edgesUniformQuantification(unsigned int)=0;
96 
97  /**
98  * @brief computes a uniform quantification for the nodes/edges
99  * associated values
100  */
101  void uniformQuantification(unsigned int k) {
102  nodesUniformQuantification(k);
103  edgesUniformQuantification(k);
104  }
105 
106  /**
107  * @brief Creates a property of the same type (e.g. tlp::DoubleProperty)
108  * The new property will be a copy of this property's values for all
109  * the elements of the graph.
110  * @param graph The Graph in which to create the new property.
111  * @return The newly created property.
112  */
113  virtual NumericProperty* copyProperty(Graph *graph) = 0;
114 
115  /**
116  * @brief Gets an iterator sorting nodes according to their values in that numeric property.
117  * @since Tulip 4.8
118  * @param sg If provided, returns an iterator on the subset of nodes defined by that subgraph.
119  * @return An iterator over graph nodes.
120  **/
121  virtual Iterator<node>* getSortedNodes(const Graph *sg = NULL, bool ascendingOrder = true);
122 
123  /**
124  * @brief Gets an iterator sorting edges according to their values in that numeric property.
125  * @since Tulip 4.8
126  * @param sg If provided, returns an iterator on the subset of edges defined by that subgraph.
127  * @param ascendingOrder defines the sort ordering (ascending or descending).
128  * @return An iterator over graph edges.
129  **/
130  virtual Iterator<edge>* getSortedEdges(const Graph *sg = NULL, bool ascendingOrder = true);
131 
132  /**
133  * @brief Gets an iterator sorting edges according to the values of their source nodes in that numeric property.
134  * @since Tulip 4.8
135  * @param sg If provided, returns an iterator on the subset of edges defined by that subgraph.
136  * @param ascendingOrder defines the sort ordering (ascending or descending).
137  * @return An iterator over graph edges.
138  **/
139  virtual Iterator<edge>* getSortedEdgesBySourceValue(const Graph *sg = NULL, bool ascendingOrder = true);
140 
141  /**
142  * @brief Gets an iterator sorting edges according to the values of their target nodes in that numeric property.
143  * @since Tulip 4.8
144  * @param sg If provided, returns an iterator on the subset of edges defined by that subgraph.
145  * @param ascendingOrder defines the sort ordering (ascending or descending).
146  * @return An iterator over graph edges.
147  **/
148  virtual Iterator<edge>* getSortedEdgesByTargetValue(const Graph *sg = NULL, bool ascendingOrder = true);
149 
150  /**
151  * @brief Gets an iterator sorting edges according to the values of their extremities in that numeric property.
152  * Vectors of two numbers (first element being the source node value, second one the target node value) are compared in that case.
153  * @since Tulip 4.8
154  * @param sg If provided, returns an iterator on the subset of edges defined by that subgraph.
155  * @param ascendingOrder defines the sort ordering (ascending or descending).
156  * @return An iterator over graph edges.
157  **/
158  virtual Iterator<edge>* getSortedEdgesByExtremitiesValues(const Graph *sg = NULL, bool ascendingOrder = true);
159 
160 };
161 
162 }
163 
164 #endif //NUMERICPROPERTY_H
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
void uniformQuantification(unsigned int k)
computes a uniform quantification for the nodes/edges associated values
Interface all numerical properties. Property values are always returned as double.