Tulip  5.4.0
Large graphs analysis and drawing
GraphMeasure.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 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef _TLPGRAPHMEASEURE_H
22 #define _TLPGRAPHMEASEURE_H
23 
24 #include <set>
25 
26 #include <tulip/Node.h>
27 #include <tulip/MutableContainer.h>
28 #include <tulip/StaticProperty.h>
29 #include <tulip/GraphTools.h>
30 
31 namespace tlp {
32 
33 class Graph;
34 class PluginProgress;
35 /**
36  * returns the average path length of a graph, that is the sum
37  * of the shortest distances for all pair of distinct nodes in that graph
38  * divided by the number of those pairs. For a pair of non connected nodes,
39  * the shorted distance is set to 0.
40  * see http://en.wikipedia.org/wiki/Average_path_length for more details
41  */
42 TLP_SCOPE double averagePathLength(const Graph *g);
43 /*
44  * return the clustering coefficient of a graph
45  * as the average of the local clustering coefficients
46  * (see clusteringCoefficient function) of all the nodes.
47  * see http://en.wikipedia.org/wiki/Clustering_coefficient for more details.
48  */
49 TLP_SCOPE double averageClusteringCoefficient(const Graph *);
50 /*
51  * assign to each node its local clustering coefficient
52  * that is the proportion of edges between the nodes within its neighbourhood
53  * divided by the number of edges that could possibly exist between them.
54  * This quantifies how close its neighbors are to being a clique.
55  * see http://en.wikipedia.org/wiki/Clustering_coefficient for more details
56  * WARNING: this function is deprecated
57  */
58 TLP_SCOPE _DEPRECATED void clusteringCoefficient(const Graph *g, MutableContainer<double> &result,
59  unsigned int maxDepth = 1);
60 /*
61  * assign to each node its local clustering coefficient
62  * that is the proportion of edges between the nodes within its neighbourhood
63  * divided by the number of edges that could possibly exist between them.
64  * This quantifies how close its neighbors are to being a clique.
65  * see http://en.wikipedia.org/wiki/Clustering_coefficient for more details
66  */
67 TLP_SCOPE void clusteringCoefficient(const Graph *g, tlp::NodeStaticProperty<double> &result,
68  unsigned int maxDepth = 1);
69 /*
70  * assign to each node of a Directed Acyclic Graph a level such that
71  * if the edge e(u,v) exists level(u) < level(v) the algorithm ensure that
72  * the number of level used is minimal.
73  * WARNING: this function is deprecated
74  */
75 TLP_SCOPE _DEPRECATED void dagLevel(const Graph *graph, MutableContainer<unsigned int> &level);
76 /*
77  * assign to each node of a graph its (in/ou/inout) degree.
78  * The weighted degree of a node is the sum of weights of
79  * all its in/out/inout edges."
80  * If no metric is specified, using a uniform metric value of 1 for all edges
81  * it assigns the usual degree of nodes (number of neighbors).",
82  * If norm is true, the measure is normalized in the following way:
83  * unweighted case => m(n) = deg(n) / (#V - 1)
84  * weighted case => m(n) = deg_w(n) / [(sum(e_w)/#E)(#V - 1)]
85  */
86 TLP_SCOPE void degree(const Graph *graph, tlp::NodeStaticProperty<double> &deg,
87  EDGE_TYPE direction = UNDIRECTED, NumericProperty *weights = nullptr,
88  bool norm = false);
89 /*
90  * assign to each node of a Directed Acyclic Graph a level such that
91  * if the edge e(u,v) exists level(u) < level(v) the algorithm ensure that
92  * the number of level used is minimal.
93  *
94  * Warning: the graph must be acyclic (no self loops).
95  */
96 TLP_SCOPE void dagLevel(const Graph *graph, tlp::NodeStaticProperty<unsigned int> &level);
97 // return the maximum value of the degree of the graph's nodes
98 TLP_SCOPE unsigned int maxDegree(const Graph *);
99 // return the minimum value of the degree of the graph's nodes
100 TLP_SCOPE unsigned int minDegree(const Graph *);
101 /*
102  * compute the maximum distance from n to all the other nodes of graph
103  * and store it into distance, (stored value is UINT_MAX for non connected nodes),
104  * if direction is set to UNDIRECTED use undirected graph, DIRECTED use directed graph
105  * and INV_DIRECTED use reverse directed graph (ie. all edges are reversed)
106  * all the edge's weight is set to 1. (it uses a bfs thus the complexity is o(m), m = |E|).
107  */
108 TLP_SCOPE _DEPRECATED unsigned int maxDistance(const Graph *graph, const node n,
109  MutableContainer<unsigned int> &distance,
110  EDGE_TYPE direction = UNDIRECTED);
111 /*
112  * compute the maximum distance from the n (graph->nodes[nPos]) to all the other nodes of graph
113  * and store it into distance, (stored value is UINT_MAX for non connected nodes),
114  * if direction is set to UNDIRECTED use undirected graph, DIRECTED use directed graph
115  * and INV_DIRECTED use reverse directed graph (ie. all edges are reversed)
116  * all the edge's weight is set to 1. (it uses a bfs thus the complexity is o(m), m = |E|).
117  */
118 TLP_SCOPE unsigned int maxDistance(const Graph *graph, const unsigned int nPos,
119  tlp::NodeStaticProperty<unsigned int> &distance,
120  EDGE_TYPE direction = UNDIRECTED);
121 
122 /*
123  * compute the maximum distance from the n (graph->nodes[nPos]) to all the other nodes of graph
124  * and store it into distance, (stored value is DBL_MAX for non connected nodes),
125  * if direction is set to UNDIRECTED use undirected graph, DIRECTED use directed graph
126  * and INV_DIRECTED use reverse directed graph (ie. all edges are reversed)
127  * Edge weights can be given, Dijkstra's algorithm is then used
128  * (the complexity is then o((m + n)log n)) otherwise
129  * all the edge's weight is set to 1. (it uses a bfs thus the complexity is o(m), m = |E|).
130  */
131 TLP_SCOPE double maxDistance(const Graph *graph, const unsigned int nPos,
132  tlp::NodeStaticProperty<double> &distance,
133  const NumericProperty *const weights,
134  EDGE_TYPE direction = UNDIRECTED);
135 } // namespace tlp
136 #endif
137 ///@endcond