V
- the graph vertex typeE
- the graph edge typepublic class ClusteringCoefficient<V,E> extends Object implements VertexScoringAlgorithm<V,Double>
Computes the local clustering coefficient of each vertex of a graph. The local clustering coefficient of a node $v$ is given by the expression: $g(v)= \sum_{s \neq v \neq t}\frac{\sigma_{st}(v)}{\sigma_{st}}$ where $\sigma_{st}$ is the total number of shortest paths from node $s$ to node $t$ and $\sigma_{st}(v)$ is the number of those paths that pass through $v$. For more details see wikipedia.
This implementation computes both the global, the local and the average clustering coefficient in an undirected or a directed network.
Global clustering coefficient was introduced in R. D. Luce and A. D. Perry (1949). "A method of matrix analysis of group structure". Psychometrika. 14 (1): 95–116. doi:10.1007/BF02289146
Local clustering coefficient was introduced in D. J. Watts and Steven Strogatz (June 1998). "Collective dynamics of 'small-world' networks". Nature. 393 (6684): 440–442. doi:10.1038/30918
This implementation also computes the global clustering coefficient as well as the average clustering coefficient.
The running time is $O(|V| + \Delta(G)^2)$ where $|V|$ is the number of vertices and $\Delta(G)$ is the maximum degree of a vertex. The space complexity is $O(|V|)$.
Constructor and Description |
---|
ClusteringCoefficient(Graph<V,E> graph)
Construct a new instance
|
Modifier and Type | Method and Description |
---|---|
double |
getAverageClusteringCoefficient()
Computes the average clustering coefficient.
|
double |
getGlobalClusteringCoefficient()
Computes the global clustering coefficient.
|
Map<V,Double> |
getScores()
Get a map with the local clustering coefficients of all vertices
|
Double |
getVertexScore(V v)
Get a vertex's local clustering coefficient
|
public ClusteringCoefficient(Graph<V,E> graph)
graph
- the input graphNullPointerException
- if graph
is null
public double getGlobalClusteringCoefficient()
A triplet is three nodes that are connected by either two (open triplet) or three (closed triplet) undirected ties.
public double getAverageClusteringCoefficient()
public Map<V,Double> getScores()
getScores
in interface VertexScoringAlgorithm<V,Double>
public Double getVertexScore(V v)
getVertexScore
in interface VertexScoringAlgorithm<V,Double>
v
- the vertexCopyright © 2019. All rights reserved.