Function Repository Resource:

TournamentGraph

Source Notebook

Generate a round-robin tournament graph

Contributed by: Alejandra Ortiz Duran

ResourceFunction["TournamentGraph"][n]

generates a balanced directed tournament on n vertices in which each vertex has nearly the same number of outgoing and incoming edges.

ResourceFunction["TournamentGraph"][n,"Cyclic"]

generates a balanced directed tournament on n vertices in which each vertex has nearly the same number of outgoing and incoming edges.

ResourceFunction["TournamentGraph"][n,"Acyclic"]

generates an acyclic directed tournament of n vertices by assigning a direction to each edge according to the vertex list order, so that the edge is directed as uv if u precedes v in the vertex list, andvu otherwise.

ResourceFunction["TournamentGraph"][n,"Random"]

generates a random directed tournament of n vertices by assigning a random direction to each edge.

Details and Options

ResourceFunction["TournamentGraph"] is a directed graph in which every pair of distinct vertices is connected by a directed edge.
TournamentGraph is an orientation of an undirected complete graph.
The name tournament comes from the round-robin tournament, where each player is paired against every other exactly once.
In ResourceFunction["TournamentGraph"][n] for odd n, every vertex has exactly (n - 1)/2 outgoing and (n - 1)/2 incoming edges. For even n, some vertices will have one extra incoming or outgoing edge.
TournamentGraph[n] gives a graph with n vertices and a "Cyclic" directed edge between every pair of vertices. A "Cyclic" tournament graph is a balanced directed tournament on n vertices in which each vertex has nearly the same number of outgoing and incoming edges. For odd n, every vertex has exactly (n - 1)/2 outgoing and (n - 1)/2 incoming edges. For even n, some vertices will have one extra incoming or outgoing edge.
ResourceFunction["TournamentGraph"] generates a Graph object.
ResourceFunction["TournamentGraph"] takes the same options as Graph.

Examples

Basic Examples (7) 

Generate a tournament graph of 7 vertices. If no type is specified, it returns a cyclic graph:

In[1]:=
ResourceFunction["TournamentGraph"][7]
Out[1]=

Generate a cyclic tournament graph of 7 vertices:

In[2]:=
ResourceFunction["TournamentGraph"][7, "Cyclic"]
Out[2]=

Generate an acyclic tournament graph of 7 vertices:

In[3]:=
ResourceFunction["TournamentGraph"][7, "Acyclic"]
Out[3]=

Generate a random tournament graph of 7 vertices:

In[4]:=
ResourceFunction["TournamentGraph"][7, "Random"]
Out[4]=

Generate the first "Cyclic" tournaments:

In[5]:=
Table[ResourceFunction["TournamentGraph"][i, "Cyclic", PlotLabel -> Subscript[T, i], ImageSize -> 80, GraphLayout -> "SpringElectricalEmbedding"], {i, 3, 5}]
Out[5]=

Generate the first "Acyclic" tournaments:

In[6]:=
Table[ResourceFunction["TournamentGraph"][i, "Acyclic", PlotLabel -> Subscript[T, i], ImageSize -> 80, GraphLayout -> "SpringElectricalEmbedding"], {i, 3, 5}]
Out[6]=

Generate "Random" tournaments:

In[7]:=
Table[ResourceFunction["TournamentGraph"][i, "Random", PlotLabel -> Subscript[T, i], ImageSize -> 80, GraphLayout -> "SpringElectricalEmbedding"], {i, 3, 5}]
Out[7]=

Options (14) 

AnnotationRules (2) 

Specify an annotation for vertices:

In[8]:=
ResourceFunction["TournamentGraph"][5, AnnotationRules -> {1 -> {VertexLabels -> "hello"}}]
Out[8]=

Specify an annotation for edges:

In[9]:=
ResourceFunction["TournamentGraph"][5, AnnotationRules -> {1 \[DirectedEdge] 2 -> {EdgeLabels -> "hello"}}]
Out[9]=

GraphHighlight (3) 

Highlight the vertex 1:

In[10]:=
ResourceFunction["TournamentGraph"][5, GraphHighlight -> {1}]
Out[10]=

Highlight the edge 23:

In[11]:=
ResourceFunction["TournamentGraph"][5, GraphHighlight -> {2 \[DirectedEdge] 3}]
Out[11]=

Highlight both vertices and edges:

In[12]:=
ResourceFunction["TournamentGraph"][5, GraphHighlight -> {1, 2, 2 \[DirectedEdge] 3}]
Out[12]=

PlotTheme (2) 

Use a common base theme:

In[13]:=
ResourceFunction["TournamentGraph"][5, PlotTheme -> "Business"]
Out[13]=

Use a monochrome theme:

In[14]:=
ResourceFunction["TournamentGraph"][5, PlotTheme -> "Monochrome"]
Out[14]=

VertexSize (3) 

By default, the size of vertices is computed automatically:

In[15]:=
ResourceFunction["TournamentGraph"][5, VertexSize -> Automatic]
Out[15]=

Specify the size of all vertices using symbolic vertex size:

In[16]:=
Table[ResourceFunction["TournamentGraph"][5, VertexSize -> s, PlotLabel -> s], {s, {Tiny, Small, Medium, Large}}]
Out[16]=

Specify the size for individual vertices:

In[17]:=
ResourceFunction["TournamentGraph"][5, VertexSize -> {1 -> 0.2, 2 -> 0.3}]
Out[17]=

VertexStyle (2) 

Style all vertices:

In[18]:=
Table[ResourceFunction["TournamentGraph"][5, VertexStyle -> style, VertexSize -> 0.3, PlotLabel -> ToString[style], ImageSize -> Tiny], {style, {Yellow, EdgeForm[Dashed]}}]
Out[18]=

Style individual vertices:

In[19]:=
ResourceFunction["TournamentGraph"][5, VertexStyle -> {1 -> Blue, 2 -> Red}, VertexSize -> 0.2]
Out[19]=

GraphLayout (2) 

The default GraphLayout is "CircularEmbedding":

In[20]:=
ResourceFunction["TournamentGraph"][7]
Out[20]=

Specify any layout:

In[21]:=
ResourceFunction["TournamentGraph"][7, GraphLayout -> "LayeredEmbedding"]
Out[21]=

Properties and Relations (2) 

The number of vertices of TournamentGraph [n] is n:

In[22]:=
n = 5;
VertexCount@ResourceFunction["TournamentGraph"][5] == n
Out[5]=

Number of edges of TournamentGraph [n] is :

In[23]:=
n = 5;
EdgeCount@ResourceFunction["TournamentGraph"][n] == (-1 + n)*n/2
Out[5]=

Publisher

Wolfram Discrete Computation

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 20 August 2025

Related Resources

License Information