node_redundancy#
- graph_tool.clustering.node_redundancy(g, prop=None)[git][source]#
Return the redundancy coefficients of the vertices of a bipartite graph.
- Parameters:
- g
Graph Graph to be used, typically bipartite. If it is directed, it is treated as undirected.
- prop
VertexPropertyMap(optional, default:None) Vertex property map of type
doublewhere results will be stored.
- g
- Returns:
- prop
VertexPropertyMap Vertex property map containing the redundancy coefficients.
- prop
See also
latapy_clusteringLocal bipartite clustering coefficient
Notes
The redundancy coefficient [latapy-basic-2008] of vertex \(v\) is the fraction of the pairs of its neighbors that remain connected through a common neighbor if \(v\) is removed,
\[r_v = \frac{|\{\{u,w\}\subseteq N_v : \exists\, x\ne v,\; x\in N_u\cap N_w\}|}{k_v(k_v-1)/2}.\]In the projection of the bipartite graph onto the vertex set opposite to \(v\), it is the fraction of the edges between the neighbors of \(v\) that would remain without \(v\). The value is zero for vertices with fewer than two neighbors. Parallel edges and self-loops are ignored.
The pairs are found either by following the paths of length two from every neighbor, or by comparing the neighborhoods of all pairs of neighbors, whichever is estimated to be faster for each vertex, so that the algorithm runs in time \(O(\sum_v\min(\sum_{u\in N_v}\sum_{x\in N_u}k_x, k_v\sum_{u\in N_v}k_u))\).
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
[latapy-basic-2008]Matthieu Latapy, Clémence Magnien and Nathalie Del Vecchio, “Basic notions for the analysis of large two-mode networks”, Social Networks 30, 31-48 (2008), DOI: 10.1016/j.socnet.2007.04.006 [sci-hub, @tor]
Examples
>>> g = gt.collection.ns["davis_southern_women"] >>> r = gt.node_redundancy(g) >>> print(r.a.mean()) 0.958458381...
The values can be visualized by drawing the network with vertex colors and sizes given by them, and with the women as circles and the events as squares:
>>> pos = gt.sfdp_layout(g) >>> cmap = matplotlib.colors.LinearSegmentedColormap.from_list( ... "gray-blue", ["#d9d9d9", "#7dabd1"]) >>> shape = g.new_vp("string", vals=np.where(g.vp.is_woman.a, "circle", ... "square")) >>> gt.graph_draw(g, pos, vertex_fill_color=r, vcmap=cmap, ... vertex_size=gt.prop_to_size(r, mi=5, ma=15), ... vertex_shape=shape, ... output="node_redundancy-davis.pdf") <...>
Redundancy coefficients of the vertices of the bipartite network of women and the social events they attended. The women are shown as circles and the events as squares. The vertex colors, from gray to blue, and the vertex sizes increase with the value.#