distinctiveness

distinctiveness#

graph_tool.centrality.distinctiveness(g, weight=None, measure='D1', alpha=1.0, mode='in', norm=False, vprop=None)[git][source]#

Calculate the distinctiveness centrality of the vertices.

Parameters:
gGraph

Graph to be used.

weightEdgePropertyMap (optional, default: None)

Edge weights, which should be at least one. If not supplied, every edge has unit weight.

measurestr (optional, default: "D1")

Variant of the centrality: "D1", "D2", "D3", "D4", or "D5" (see below).

alphafloat (optional, default: 1.)

Exponent \(\alpha\) of the penalty on the neighbors with many connections, which should be at least one.

modestr (optional, default: "in")

For directed graphs, the edges over which the sum runs: "in" or "out" (see below). It is ignored for undirected graphs.

normbool (optional, default: False)

If True, the values will be rescaled with the lower and upper bounds given below.

vpropVertexPropertyMap (optional, default: None)

Vertex property map to store the values.

Returns:
distinctivenessVertexPropertyMap

A vertex property map with the distinctiveness values.

See also

diversity

Diversity of the edge weights of each vertex

burt_effective_size

Burt’s effective size

Notes

Distinctiveness centrality [fronzetti-distinctiveness-2020] values the connections of a vertex more if they lead to vertices that have few other connections, which makes them less redundant. Its five variants are sums over the neighbors \(j\) of a vertex \(i\),

\[\begin{split}D_1(i) &= \sum_j w_{ij}\log_{10}\frac{n-1}{g_j^\alpha},\\ D_2(i) &= \sum_j \log_{10}\frac{n-1}{g_j^\alpha},\\ D_3(i) &= \sum_j w_{ij}\log_{10} \frac{W}{\sum_k w_{jk}^\alpha - w_{ij}^\alpha + 1},\\ D_4(i) &= \sum_j w_{ij}\frac{w_{ij}^\alpha}{\sum_k w_{jk}^\alpha},\\ D_5(i) &= \sum_j \frac{1}{g_j^\alpha},\end{split}\]

where \(n\) is the number of vertices, \(w_{ij}\) is the weight of the edge between \(i\) and \(j\), \(g_j\) is the degree of \(j\), and \(W\) is the total weight of the edges. The variants \(D_2\) and \(D_5\) ignore the weights, and \(D_1\) equals \(D_2\) for unit weights. With \(\alpha > 1\), the contributions of the neighbors with many connections to \(D_1\), \(D_2\), and \(D_3\) become negative.

For directed graphs with mode == "in", the sums run over the in-neighbors \(j\) of \(i\), with the weights \(w_{ji}\), and \(g_j\) and \(\sum_k w_{jk}^\alpha\) are the out-degree and the out-strength of \(j\), so that an incoming edge counts more if it comes from a vertex with few out-neighbors. With mode == "out", the sums run over the out-neighbors, and \(g_j\) and the strength of \(j\) are computed from its in-edges.

The conventions are those of the reference implementation of the authors [distinctiveness-code]: self-loops are ignored, parallel edges count as a single edge with the sum of their weights (also in \(g_j\), which is thus the number of distinct neighbors), and each edge of an undirected graph counts once in \(W\).

If norm == True, the values are rescaled as \((D - D^-) / (D^+ - D^-)\), with the loose lower and upper bounds of the reference implementation, which are attained by the vertices of a star or of a complete graph,

Variant

Lower bound \(D^-\)

Upper bound \(D^+\)

\(D_1\)

\((1-\alpha)M(n-1)\log_{10}(n-1)\)

\(M(n-1)\log_{10}(n-1)\)

\(D_2\)

\((1-\alpha)(n-1)\log_{10}(n-1)\)

\((n-1)\log_{10}(n-1)\)

\(D_3\)

\((n-1)M\log_{10}\frac{(n-2)M + m}{(n-2)M^\alpha + 1}\), or zero if \(m-1 > (n-2)(M^\alpha - M)\)

\((n-1)M\log_{10}(cMn(n-1))\), with \(c=1/2\) for undirected and \(c=1\) for directed graphs

\(D_4\)

0

\((n-1)M\)

\(D_5\)

0

\(n-1\)

where \(m\) and \(M\) are the smallest and largest edge weights. The bounds hold only for \(\alpha\ge 1\) and \(n\ge 3\), and otherwise the normalization raises an error. For graphs without edges, all values are zero.

The algorithm takes time \(O(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.

References

[fronzetti-distinctiveness-2020]

Andrea Fronzetti Colladon and Maurizio Naldi, “Distinctiveness centrality in social networks”, PLoS ONE 15, e0233276 (2020), DOI: 10.1371/journal.pone.0233276 [sci-hub, @tor]

[distinctiveness-code]

Andrea Fronzetti Colladon, “distinctiveness”, iandreafc/distinctiveness

Examples

>>> g = gt.collection.data["lesmis"]
>>> d = gt.distinctiveness(g, g.ep.value, measure="D1")
>>> print(g.vp.label[d.a.argmax()], d.a.max())
Valjean 144.110061187...

The values can be visualized by drawing the network with vertex colors and sizes given by them, and the edge widths given by the weights:

>>> cmap = matplotlib.colors.LinearSegmentedColormap.from_list(
...     "gray-blue", ["#d9d9d9", "#7dabd1"])
>>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=d, vcmap=cmap,
...               vertex_size=gt.prop_to_size(d, mi=5, ma=15),
...               edge_pen_width=gt.prop_to_size(g.ep.value, mi=0.5, ma=4),
...               output="distinctiveness-lesmis.pdf")
<...>
../_images/distinctiveness-lesmis.png

Distinctiveness centrality \(D_1\) of the vertices of the network of co-appearances of the characters of Les Misérables, with the numbers of co-appearances as edge weights. The vertex colors, from gray to blue, and the vertex sizes increase with the value. The edge widths increase with the weights.#