GraphTheory[RandomGraphs] - Maple Programming Help

Home : Support : Online Help : Mathematics : Discrete Mathematics : Graph Theory : GraphTheory Package : RandomGraphs : GraphTheory/RandomGraphs/RandomTournament

GraphTheory[RandomGraphs]

 RandomTournament

 Calling Sequence RandomTournament(n,options)

Parameters

 n - positive integer or list of vertex labels options - sequence of options (see below)

Description

 • RandomTournament(n) creates a random tournament on n vertices. This is a directed graph such that for every pair of vertices u and v either the arc u to v or the arc v to u is in the digraph.
 • If the first input is a positive integer n, then the vertices are labeled 1,2,...,n.  Alternatively you may specify the vertex labels in a list.
 • If the option weights=m..n is specified, where m <= n are integers, the graph is a weighted graph with edge weights chosen from [m,n] uniformly at random.  The weight matrix W in the graph has datatype=integer, and if the edge from vertex i to j is not in the graph then W[i,j] = 0.
 • If the option weights=x..y where x <= y are decimals is specified, the graph is a weighted graph with numerical edge weights chosen from [x,y] uniformly at random.  The weight matrix W in the graph has datatype=float[8], that is, double precision floats (16 decimal digits), and if the edge from vertex i to j is not in the graph then W[i,j] = 0.0.
 • If the option weights=f where f is a function (a Maple procedure) that returns a number (integer, rational, or decimal number), then f is used to generate the edge weights.  The weight matrix W in the graph has datatype=anything, and if the edge from vertex i to j is not in the graph then W[i,j] = 0.
 • The random number generator used can be seeded using the randomize function.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $\mathrm{with}\left(\mathrm{RandomGraphs}\right):$
 > $T≔\mathrm{RandomTournament}\left(5\right)$
 ${T}{≔}{\mathrm{Graph 1: a directed unweighted graph with 5 vertices and 10 arc\left(s\right)}}$ (1)
 > $T≔\mathrm{RandomTournament}\left(5,\mathrm{weights}=1..5\right)$
 ${T}{≔}{\mathrm{Graph 2: a directed weighted graph with 5 vertices and 10 arc\left(s\right)}}$ (2)
 > $\mathrm{IsTournament}\left(T\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{WeightMatrix}\left(T\right)$
 $\left[\begin{array}{rrrrr}{0}& {5}& {2}& {0}& {5}\\ {0}& {0}& {0}& {0}& {3}\\ {0}& {1}& {0}& {2}& {0}\\ {3}& {3}& {0}& {0}& {0}\\ {0}& {0}& {3}& {3}& {0}\end{array}\right]$ (4)