birank

Contents

birank#

graph_tool.centrality.birank(g, top=None, weight=None, alpha=None, beta=None, top_pers=None, bottom_pers=None, epsilon=1e-06, max_iter=100, vprop=None)[git][source]#

Calculate the BiRank of the vertices of a bipartite graph.

Parameters:
gGraph

Graph to be used. It is treated as undirected, and the edges between vertices of the same set are ignored.

topVertexPropertyMap (optional, default: None)

Boolean vertex property map with the vertices of the top set. If not given, the bipartition found by is_bipartite() is used, and the graph must be bipartite.

weightEdgePropertyMap (optional, default: None)

Edge weights. If not supplied, every edge has unit weight.

alphafloat (optional, default: None)

Damping factor of the top vertices. If not given, it is 0.8 if top_pers is given, otherwise 1.

betafloat (optional, default: None)

Damping factor of the bottom vertices. If not given, it is 0.8 if bottom_pers is given, otherwise 1.

top_persVertexPropertyMap (optional, default: None)

Non-negative personalization (query) values of the top vertices.

bottom_persVertexPropertyMap (optional, default: None)

Non-negative personalization (query) values of the bottom vertices.

epsilonfloat (optional, default: 1e-6)

Convergence condition. The iteration stops when the mean relative change of the values of both sets is below this value.

max_iterint (optional, default: 100)

Maximum number of iterations.

vpropVertexPropertyMap (optional, default: None)

Vertex property map to store the values.

Returns:
birankVertexPropertyMap

A vertex property map with the BiRank values of the vertices of both sets.

See also

hits

Authority and hub centralities

pagerank

PageRank centrality

Notes

BiRank [he-birank-2017] ranks the vertices of the two sets of a bipartite graph, so that the vertices connected to highly ranked vertices are also highly ranked, with the iteration

\[\boldsymbol p \leftarrow \alpha \boldsymbol S^\top\boldsymbol u + (1-\alpha)\boldsymbol p_0, \qquad \boldsymbol u \leftarrow \beta \boldsymbol S\boldsymbol p + (1-\beta)\boldsymbol u_0,\]

where \(\boldsymbol p\) and \(\boldsymbol u\) are the values of the top and bottom vertices, \(\boldsymbol p_0\) and \(\boldsymbol u_0\) their personalization values, and \(\boldsymbol S = \boldsymbol D_u^{-1/2}\boldsymbol W\boldsymbol D_p^{-1/2}\) is the symmetrically normalized weighted biadjacency matrix, with entries \(S_{bt} = w_{bt}/\sqrt{d_bd_t}\), where \(w_{bt}\) is the total weight of the edges between the bottom vertex \(b\) and the top vertex \(t\), and \(d_v\) is the weighted degree of \(v\) counting only the edges between the two sets (replaced by one if it is zero). The personalization values are zero if not given. In each iteration \(\boldsymbol p\) is updated first, and then \(\boldsymbol u\) from the new \(\boldsymbol p\). If \(\alpha=\beta=1\), the values of each set are normalized to sum to one at the end. The iteration starts from uniform values of the top vertices, it stops when the sums over the vertices of each set of the changes \(|x' - x|/\max(1, x)\) of their values are below epsilon times the number of vertices of the set, and each iteration takes time \(O(V + E)\). If it does not converge in max_iter iterations, a RuntimeError is raised.

References

[he-birank-2017]

Xiangnan He, Ming Gao, Min-Yen Kan, and Dingxian Wang, “BiRank: Towards ranking on bipartite graphs”, IEEE Transactions on Knowledge and Data Engineering 29, 57-71 (2017), DOI: 10.1109/TKDE.2016.2611584 [sci-hub, @tor], arXiv: 1708.04396

Examples

>>> g = gt.collection.ns["davis_southern_women"]
>>> br = gt.birank(g, top=g.vp.is_woman)
>>> print(br.a[:18].argmax(), br.a[:18].max())
13 0.072372439...

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=br, vcmap=cmap,
...               vertex_size=gt.prop_to_size(br, mi=5, ma=15),
...               vertex_shape=shape,
...               output="birank-davis.pdf")
<...>
../_images/birank-davis.png

BiRank 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.#