edge_clustering

edge_clustering#

graph_tool.clustering.edge_clustering(g, eprop=None)[git][source]#

Return the edge clustering coefficients.

Parameters:
gGraph

Graph to be used. If it is directed, it is treated as undirected.

epropEdgePropertyMap (optional, default: None)

Edge property map of type double where results will be stored.

Returns:
epropEdgePropertyMap

Edge property containing the edge clustering coefficients.

See also

local_clustering

Local clustering coefficient

generalized_degree

Generalized degree

graph_tool.structure.truss_decomposition

K-truss decomposition

graph_tool.centrality.dispersion

Dispersion 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 nan if 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")
<...>
../_images/edge_clustering-football.png

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.#