This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.


digraph_transitivity(graph, /)#

Compute the transitivity of a directed graph.

The transitivity of a directed graph is defined in [Fag], Eq.8:

\[`c=3 \times \frac{\text{number of triangles}}{\text{number of all possible triangles}}`\]

A triangle is a connected triple of nodes. Different edge orientations counts as different triangles.

This function is multithreaded and will run launch a thread pool with threads equal to the number of CPUs by default. You can tune the number of threads with the RAYON_NUM_THREADS environment variable. For example, setting RAYON_NUM_THREADS=4 would limit the thread pool to 4 threads.


The function implicitly assumes that there are no parallel edges or self loops. It may produce incorrect/unexpected results if the input graph has self loops or parallel edges.


graph (PyDiGraph) – Directed graph to be used.



Return type:



Clustering in complex directed networks by G. Fagiolo, Physical Review E, 76(2), 026107 (2007)