dispersion

Contents

dispersion#

graph_tool.centrality.dispersion(g, norm=True, alpha=1.0, b=0.0, c=0.0)[git][source]#

Calculate the dispersion of the edges.

Parameters:
gGraph

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

normbool (optional, default: True)

If True, the normalized dispersion is computed.

alphafloat (optional, default: 1.)

Exponent of the normalized dispersion.

bfloat (optional, default: 0.)

Constant added to the dispersion in the normalization.

cfloat (optional, default: 0.)

Constant added to the embeddedness in the normalization.

Returns:
disp_stEdgePropertyMap

The dispersion of the target of each edge in the ego network of its source.

disp_tsEdgePropertyMap

The dispersion of the source of each edge in the ego network of its target.

See also

graph_tool.clustering.edge_clustering

Edge clustering coefficient

graph_tool.structure.vertex_similarity

Vertex similarity

Notes

The dispersion [backstrom-romantic-2014] of a neighbor \(v\) of a vertex \(u\) measures how much the common neighbors of \(u\) and \(v\) are not otherwise connected in the ego network of \(u\) (its neighbors and itself). It is the number of pairs \(s,t\) of common neighbors of \(u\) and \(v\) that are not adjacent and have no common neighbor in the ego network of \(u\) other than \(u\) and \(v\),

\[\mathrm{disp}(u,v) = \sum_{\{s,t\}\subseteq C_{uv}} [t\notin N_s]\,[N_s\cap N_t\cap N_u\subseteq\{u,v\}],\]

where \(N_s\) is the set of neighbors of \(s\), \(C_{uv} = N_u\cap N_v\setminus\{u,v\}\) the set of common neighbors, the sum is over the unordered pairs of distinct vertices, and \([\cdot]\) is one if the condition holds and zero otherwise. In [backstrom-romantic-2014] it is used to identify the romantic partners of \(u\) among its neighbors. If norm == True, the normalized dispersion

\[\frac{(\mathrm{disp}(u,v) + b)^\alpha}{\mathrm{emb}(u,v) + c}\]

is computed instead, where \(\mathrm{emb}(u,v)\) is the number of common neighbors of \(u\) and \(v\), i.e. \(|C_{uv}|\) (the denominator is omitted if it vanishes). Self-loops and parallel edges are ignored, and the unnormalized dispersion of a self-loop is zero. Since it is asymmetric, the dispersion of both directions of each edge is returned.

The pairs of common neighbors of each edge are inspected, in time \(O(\sum_{(u,v)}\sum_{s\in N_u\cap N_v} k_s + k_{uv}^2 \langle k \rangle)\), where \(k_{uv}\) is the number of common neighbors.

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

[backstrom-romantic-2014] (1,2)

Lars Backstrom and Jon Kleinberg, “Romantic partnerships and the dispersion of social ties: A network analysis of relationship status on Facebook”, in Proceedings of the 17th ACM Conference on Computer Supported Cooperative Work & Social Computing, 831-841 (2014), DOI: 10.1145/2531602.2531642 [sci-hub, @tor], arXiv: 1310.6753

Examples

>>> g = gt.collection.data["karate"]
>>> d_st, d_ts = gt.dispersion(g)
>>> e = g.edge(0, 1)
>>> print(d_st[e], d_ts[e])
2.142857142... 2.142857142...

The edges with positive dispersion of their target in the ego network of their source can be highlighted in a drawing of the network:

>>> ecolor = g.new_ep("string", vals=np.where(d_st.a > 0, "#377eb8",
...                                           "#d9d9d9"))
>>> ewidth = g.new_ep("double", vals=1 + 6 * d_st.a / d_st.a.max())
>>> gt.graph_draw(g, g.vp.pos, vertex_fill_color="#cccccc", vertex_size=5,
...               edge_color=ecolor, edge_pen_width=ewidth,
...               output="dispersion-karate.pdf")
<...>
../_images/dispersion-karate.png

Normalized dispersion of the edges of Zachary’s karate club network, for the target of each edge in the ego network of its source. The edges with positive dispersion are shown in blue, with widths increasing with the value, and the others in light gray.#