is_tournament

Contents

is_tournament#

graph_tool.structure.is_tournament(g)[git][source]#

Check whether a directed graph is a tournament.

Parameters:
gGraph

Directed graph.

Returns:
tournamentbool

True if there is exactly one edge between every pair of distinct vertices, and no self-loops.

See also

tournament_hamiltonian_path

Hamiltonian path of a tournament

graph_tool.generation.generate_tournament

Random tournament

Notes

A tournament is an orientation of a complete graph, i.e. a directed graph without self-loops in which every pair of distinct vertices is joined by exactly one edge, in one of the two directions. Its score sequence is given by the out-degrees. The time is \(O(V + E)\).

Examples

>>> g = gt.Graph([(i, j) if (i + j) % 2 else (j, i)
...               for i in range(6) for j in range(i + 1, 6)])
>>> print(gt.is_tournament(g))
True