Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

networkx.algorithms.tournament.random_tournament

random_tournament(n, seed=None)[source]

Returns a random tournament graph on n nodes.

Parameters
nint

The number of nodes in the returned graph.

seedinteger, random_state, or None (default)

Indicator of random number generation state. See Randomness.

Returns
GDiGraph

A tournament on n nodes, with exactly one directed edge joining each pair of distinct nodes.

Notes

This algorithm adds, for each pair of distinct nodes, an edge with uniformly random orientation. In other words, binom{n}{2} flips of an unbiased coin decide the orientations of the edges in the graph.