convergence_degree

convergence_degree#

graph_tool.centrality.convergence_degree(g, eprop=None)[git][source]#

Calculate the convergence degree of each edge.

Parameters:
gGraph

Graph to be used.

epropEdgePropertyMap (optional, default: None)

Edge property map to store the values.

Returns:
convergenceEdgePropertyMap

An edge property map with the convergence degree values.

See also

betweenness

Shortest-path betweenness centrality

graph_tool.structure.shortest_distance

Shortest-path distances

Notes

For an edge \((u,v)\), the input set \(I_{uv}\) is the set of vertices from which some shortest path passes along the edge, i.e. the vertices \(s\) with \(d(s,u) + 1 = d(s,v)\), and the output set \(O_{uv}\) is the set of vertices to which some shortest path passes along it, i.e. the vertices \(t\) with \(d(v,t) + 1 = d(u,t)\). The convergence degree of the edge is

\[c_{uv} = \frac{|I_{uv}| - |O_{uv}|}{|I_{uv}| + |O_{uv}|},\]

which is positive if the shortest paths along the edge converge (they start in a larger set than the one in which they end) and negative if they diverge. For undirected graphs, the absolute value is taken, so that the orientation of the edges does not matter. Self-loops lie on no shortest path, and their value is nan.

The input and output sets are obtained with a breadth-first search from each vertex (along the edges and, for the output sets of directed graphs, against them), in time \(O(V(V+E))\).

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.

Examples

>>> g = gt.collection.data["karate"]
>>> c = gt.convergence_degree(g)
>>> print(c.a.mean(), c.a.max())
0.601716290... 0.941176470...

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="convergence_degree-karate.pdf")
<...>
../_images/convergence_degree-karate.png

Convergence degree of the edges of Zachary’s karate club network. The edge colors, from gray to blue, and the edge widths increase with the value.#