gives the reciprocity of a graph g.
GraphReciprocity[{vw,…}]
uses rules vw to specify the graph g.
GraphReciprocity
gives the reciprocity of a graph g.
GraphReciprocity[{vw,…}]
uses rules vw to specify the graph g.
Details and Options
- The reciprocity of a graph g is the fraction of reciprocal edges over all edges of g.
- For a directed graph, the edges
and
are reciprocal and form a cycle of length 2. - For an undirected graph, all edges are reciprocal.
- GraphReciprocity works with undirected graphs, directed graphs, and weighted graphs.
Examples
open all close allBasic Examples (2)
Scope (6)
GraphReciprocity works with undirected graphs:
GraphReciprocity[[image]]GraphReciprocity[[image]]GraphReciprocity[[image]]GraphReciprocity[[image]]Use rules to specify the graph:
GraphReciprocity[{1 -> 2, 1 -> 3, 2 -> 3, 2 -> 4, 3 -> 1, 3 -> 4}]GraphReciprocity works with large graphs:
g = RandomGraph[UniformGraphDistribution[10 ^ 4, 10 ^ 5, DirectedEdges -> True]];Timing[GraphReciprocity[g]]Applications (3)
GraphReciprocity measures the number of directed edges that are bidirectional:
g = CycleGraph[4, DirectedEdges -> True];Table[Labeled[g = EdgeAdd[g, iMod[i - 1, 4, 1]], N@GraphReciprocity[g]], {i, 4}]Test whether a square matrix is structurally symmetric:
m = SparseArray[{Band[{1, 2}] -> 1, Band[{2, 1}] -> -1}, {25, 25}];GraphReciprocity[AdjacencyGraph[Unitize[m]]] == 1Distribution of reciprocity in UniformGraphDistribution[n,m,DirectedEdges->True]:
𝒢 = UniformGraphDistribution[9, 40, DirectedEdges -> True];data = GraphReciprocity /@ RandomGraph[𝒢, 1000];Histogram[data]The expected value is (m-1)/(n(n-1)-1):
N[{Mean[data], 39 / 71}]Properties & Relations (3)
The graph reciprocity is between 0 and 1:
RandomGraph[UniformGraphDistribution[5, 10, DirectedEdges -> True]]N[GraphReciprocity[%]]A bidirectional directed graph has reciprocity 1:
DirectedGraph[StarGraph[4]]GraphReciprocity[%]An undirected graph also has reciprocity 1:
StarGraph[8]GraphReciprocity[%]Related Guides
Text
Wolfram Research (2012), GraphReciprocity, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphReciprocity.html (updated 2015).
CMS
Wolfram Language. 2012. "GraphReciprocity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GraphReciprocity.html.
APA
Wolfram Language. (2012). GraphReciprocity. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphReciprocity.html
BibTeX
@misc{reference.wolfram_2026_graphreciprocity, author="Wolfram Research", title="{GraphReciprocity}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/GraphReciprocity.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_graphreciprocity, organization={Wolfram Research}, title={GraphReciprocity}, year={2015}, url={https://reference.wolfram.com/language/ref/GraphReciprocity.html}, note=[Accessed: 13-June-2026]}