GraphTheory[RandomGraphs] - Maple Programming Help

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

GraphTheory[RandomGraphs]

 RandomNetwork

 Calling Sequence RandomNetwork(n,p,options) RandomNetwork(n,p,q,options) RandomNetwork(V,p,options) RandomNetwork(V,p,q,options)

Parameters

 n - positive integer, larger than 1 p - real number between 0.0 and 1.0 V - list of vertices q - real number between 0.0 and 1.0 options - sequence of options (see below)

Description

 • RandomNetwork(n,p) creates a directed unweighted network on n vertices. The larger p is, the larger the number of levels in the network.
 • RandomNetwork(V,p) does the same thing except that the vertex labels are chosen from the list V.
 • If the option acyclic is specified, a random acyclic network is created.
 • You can optionally specify q which is a real number between 0.0 and 1.0.  The result is a random network such that each possible arc is present with probability q. The default value for q is 0.5.
 • If the option weights=m..n is specified, where m <= n are integers, the network 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 network 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 network 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):$
 > $N≔\mathrm{RandomNetwork}\left(10,0.5\right)$
 ${N}{:=}{\mathrm{Graph 1: a directed unweighted graph with 10 vertices and 28 arc\left(s\right)}}$ (1)
 > $\mathrm{IsNetwork}\left(N\right)$
 $\left\{{1}\right\}{,}\left\{{10}\right\}$ (2)
 > $\mathrm{DrawGraph}\left(N\right)$
 > $N≔\mathrm{RandomNetwork}\left(\left[a,b,c,d,e\right],0.5,\mathrm{acyclic}\right)$
 ${N}{:=}{\mathrm{Graph 2: a directed unweighted graph with 5 vertices and 6 arc\left(s\right)}}$ (3)
 > $\mathrm{DrawNetwork}\left(N\right)$
 > $N≔\mathrm{RandomNetwork}\left(10,0.2,\mathrm{acyclic},\mathrm{weights}=1..5\right)$
 ${N}{:=}{\mathrm{Graph 3: a directed weighted graph with 10 vertices and 31 arc\left(s\right)}}$ (4)
 > $\mathrm{WeightMatrix}\left(N\right)$
 $\left[\begin{array}{rrrrrrrrrr}{0}& {1}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {3}& {1}& {3}& {2}& {2}& {2}& {3}& {0}\\ {0}& {0}& {0}& {1}& {2}& {0}& {1}& {0}& {2}& {0}\\ {0}& {0}& {0}& {0}& {4}& {1}& {2}& {0}& {2}& {4}\\ {0}& {0}& {0}& {0}& {0}& {1}& {1}& {3}& {1}& {4}\\ {0}& {0}& {0}& {0}& {0}& {0}& {5}& {2}& {3}& {4}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {2}& {5}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {4}& {2}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {4}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\end{array}\right]$ (5)
 > $\mathrm{MaxFlow}\left(N,1,10\right)$
 ${1}{,}\left[\begin{array}{rrrrrrrrrr}{0}& {1}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {1}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {1}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {1}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {1}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {1}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {1}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {1}\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}\end{array}\right]$ (6)