graph_tool.topology.edge_reciprocity#

graph_tool.topology.edge_reciprocity(g, weight=None)[source]#

Calculate the edge reciprocity of the graph.

Parameters:
gGraph

Graph to be used edges.

weightEdgePropertyMap (optional, default: None)

Edge weights.

Returns:
reciprocityfloat

The reciprocity value.

Notes

The edge [reciprocity] is defined as \(E^\leftrightarrow/E\), where \(E^\leftrightarrow\) and \(E\) are the number of bidirectional and all edges in the graph, respectively.

If weights are provided, the number of edges is replaced by the sum of edge weights.

The algorithm runs with complexity \(O(E + V)\).

If enabled during compilation, this algorithm runs in parallel.

References

[reciprocity]

S. Wasserman and K. Faust, “Social Network Analysis”. (Cambridge University Press, Cambridge, 1994)

[lopez-reciprocity-2007]

Gorka Zamora-López, Vinko Zlatić, Changsong Zhou, Hrvoje Štefančić, and Jürgen Kurths “Reciprocity of networks with degree correlations and arbitrary degree sequences”, Phys. Rev. E 77, 016106 (2008) DOI: 10.1103/PhysRevE.77.016106 [sci-hub, @tor], arXiv: 0706.3372

Examples

>>> g = gt.Graph()
>>> g.add_vertex(2)
<...>
>>> g.add_edge(g.vertex(0), g.vertex(1))
<...>
>>> gt.edge_reciprocity(g)
0.0
>>> g.add_edge(g.vertex(1), g.vertex(0))
<...>
>>> gt.edge_reciprocity(g)
1.0
>>> g = gt.collection.data["pgp-strong-2009"]
>>> gt.edge_reciprocity(g)
0.692196963163...