clustering
Module for clustering coefficient calculations.
avg_clustering_coefficient
¶
Calculates the average clustering coefficient \(C\) of the graph \(G=(V, E)\).
Given the local clustering coefficients \(C_u\) for all nodes \(u \in V\), the average clustering coefficient is defined as their mean:
Warning
This measurement of global clustering should not be confused with the global clustering coefficient defined as the fraction of closed paths of length two over all paths of length two in the graph.
Reference
Proposed by Watts and Strogatz in their seminal paper on "Collective dynamics of 'small-world' networks"1. Further details can be found in in Chapter 7.3 in Networks2 by Mark Newman.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
g
|
pathpyG.core.graph.Graph
|
The graph in which to calculate the average clustering coefficient. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The average clustering coefficient of the graph. |
Source code in src/pathpyG/statistics/clustering.py
closed_triads
¶
Calculates the set of edges that represent a closed triad around a given node \(v\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
g
|
pathpyG.core.graph.Graph
|
The graph in which to calculate the list of closed triads. |
required |
v
|
str
|
The node around which to calculate the closed triads. |
required |
Source code in src/pathpyG/statistics/clustering.py
local_clustering_coefficient
¶
Calculates the local clustering coefficient \(C_u\) for a given node \(u\) from a graph \(G=(V, E)\).
The local clustering coefficient is defined as the fraction of closed triads around node \(u\) over the number of possible triads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
g
|
pathpyG.core.graph.Graph
|
The graph in which to calculate the clustering coefficient. |
required |
u
|
str
|
The node for which to calculate the clustering coefficient. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The local clustering coefficient of node u. |