transitivity#

transitivity(G)[source]#

Compute graph transitivity, the fraction of all possible triangles present in G.

Possible triangles are identified by the number of “triads” (two edges with a shared vertex).

The transitivity is

\[T = 3\frac{\#triangles}{\#triads}.\]
Parameters:
Ggraph
Returns:
outfloat

Transitivity

Notes

Self loops are ignored.

Examples

>>> G = nx.complete_graph(5)
>>> print(nx.transitivity(G))
1.0
----

Additional backends implement this function

cugraphGPU-accelerated backend.

Directed graphs are not yet supported.

graphblas : OpenMP-enabled sparse linear algebra backend.