edge_clustering#
- graph_tool.clustering.edge_clustering(g, eprop=None)[git][source]#
Return the edge clustering coefficients.
- Parameters:
- g
Graph Graph to be used. If it is directed, it is treated as undirected.
- eprop
EdgePropertyMap(optional, default:None) Edge property map of type
doublewhere results will be stored.
- g
- Returns:
- eprop
EdgePropertyMap Edge property containing the edge clustering coefficients.
- eprop
See also
local_clusteringLocal clustering coefficient
generalized_degreeGeneralized degree
graph_tool.structure.truss_decompositionK-truss decomposition
graph_tool.centrality.dispersionDispersion of the edges
Notes
The edge clustering coefficient [radicchi-defining-2004] of an edge \((u,v)\) is
\[c_{uv} = \frac{z_{uv} + 1}{\min(k_u - 1, k_v - 1)},\]where \(z_{uv}\) is the number of triangles that contain the edge, and \(k_u\) the number of neighbors of \(u\). The term \(+1\) avoids zero values for edges in no triangle. Edges between communities tend to have small values, which is the basis of the divisive community detection of [radicchi-defining-2004]. The value is
nanif an endpoint has a single neighbor, or for self-loops. Parallel edges are treated as a single edge. The algorithm runs in time \(O(\sum_{uv} (k_u + k_v))\).Parallel implementation.
If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.
References
[radicchi-defining-2004] (1,2)Filippo Radicchi, Claudio Castellano, Federico Cecconi, Vittorio Loreto and Domenico Parisi, “Defining and identifying communities in networks”, Proc. Natl. Acad. Sci. USA 101, 2658-2663 (2004), DOI: 10.1073/pnas.0400054101 [sci-hub, @tor], arXiv: cond-mat/0309488
Examples
>>> g = gt.collection.data["football"] >>> c = gt.edge_clustering(g) >>> print(c.a.min(), c.a.max()) 0.0909090909... 1.0
The values can be visualized by drawing the network with edge colors and widths given by them:
>>> ecmap = matplotlib.colors.LinearSegmentedColormap.from_list( ... "gray-blue", ["#d9d9d9", "#377eb8"]) >>> gt.graph_draw(g, g.vp.pos, vertex_fill_color="#cccccc", ... edge_color=c, ecmap=ecmap, ... edge_pen_width=gt.prop_to_size(c, mi=0.5, ma=4), ... output="edge_clustering-football.pdf") <...>
Edge clustering coefficients of the network of American college football games. The edge colors, from gray to blue, and the edge widths increase with the value.#