communicability

communicability#

graph_tool.centrality.communicability(g, vertex_pairs=None, sim_map=None)[git][source]#

Return the communicability between pairs of vertices.

Parameters:
gGraph

Graph to be used.

vertex_pairsiterable of pairs of integers (optional, default: None)

Pairs of vertices. If omitted, all pairs are considered.

sim_mapVertexPropertyMap (optional, default: None)

If provided, and vertex_pairs is None, the values will be stored in this vector-valued property map.

Returns:
Gnumpy.ndarray or VertexPropertyMap

The communicabilities of the given pairs, or a vector-valued property map with the communicabilities of every vertex to all others.

See also

subgraph_centrality

Subgraph centrality

estrada_index

Estrada index

communicability_betweenness

Communicability betweenness centrality

Notes

The communicability [estrada-communicability-2008] between vertices \(p\) and \(q\) is the weighted number of walks between them, with walks of length \(l\) weighted by \(1/l!\),

\[G_{pq} = \sum_{l=0}^{\infty}\frac{[\boldsymbol A^l]_{pq}}{l!} = [e^{\boldsymbol A}]_{pq},\]

where \(\boldsymbol A\) is the adjacency matrix (see adjacency()), whose entries count parallel edges, and self-loops twice for undirected graphs. For directed graphs, \(G_{pq}\) counts the walks from \(p\) to \(q\), as in [estrada-communicability-2008], i.e. \(A_{ij}\) above counts the edges \(i\to j\) (the transpose of the matrix returned by adjacency()), and the value returned for the pair (p, q) (or sim_map[p][q]) is \(G_{pq}\). It is computed from the eigendecomposition of the adjacency matrix (or from the matrix exponential, for directed graphs), in time \(O(V^3)\) and memory \(O(V^2)\).

References

[estrada-communicability-2008] (1,2)

Ernesto Estrada and Naomichi Hatano, “Communicability in complex networks”, Physical Review E 77, 036111 (2008), DOI: 10.1103/PhysRevE.77.036111 [sci-hub, @tor], arXiv: 0707.0756

Examples

>>> g = gt.collection.data["karate"]
>>> print(gt.communicability(g, [(0, 33), (0, 1)]))
[89.9498739... 92.9063968...]

The communicabilities between one vertex and all others can be visualized by drawing the network with vertex colors and sizes given by them:

>>> G = gt.communicability(g, [(0, v) for v in g.vertices()])
>>> c = g.new_vp("double", vals=G)
>>> cmap = matplotlib.colors.LinearSegmentedColormap.from_list(
...     "gray-blue", ["#d9d9d9", "#7dabd1"])
>>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=c, vcmap=cmap,
...               vertex_size=gt.prop_to_size(c, mi=5, ma=15),
...               output="communicability-karate.pdf")
<...>
../_images/communicability-karate.png

Communicability between vertex 0 and the vertices of Zachary’s karate club network. The vertex colors, from gray to blue, and the vertex sizes increase with the value.#