RandomDigraph - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


GraphTheory[RandomGraphs]

  

RandomDigraph

  

generate random digraph

 

Calling Sequence

Parameters

Options

Description

Examples

Calling Sequence

RandomDigraph(V, p, options)

RandomDigraph(V, m, options)

RandomDigraph(n, p, options)

RandomDigraph(n, m, options)

Parameters

V

-

list of vertices

n

-

positive integer

p

-

numerical value in the closed range [0.0,1.0]

m

-

non-negative integer

options

-

(optional) equation(s) of the form option=value where option is one of seed or weights

Options

• 

seed = integer or none

  

Seed for the random number generator. When an integer is specified, this is equivalent to calling randomize(seed).

• 

weights = range or function

  

If the option weights=m..n is specified, where mn are integers, the graph returned 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 xy are floating-point numbers is specified, the graph returned 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.

Description

• 

RandomDigraph(n,m) creates a directed unweighted graph on n vertices and m edges, where the m edges are chosen uniformly at random.

• 

RandomDigraph(n,p) creates a directed unweighted graph on n vertices where each possible edge is present with probability p.

• 

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.

• 

The random number generator used can be seeded with the seed option or by using the randomize function.

Examples

withGraphTheory:

withRandomGraphs:

GRandomDigraph10,0.5

GGraph 1: a directed graph with 10 vertices and 39 arc(s)

(1)

IsDirectedG

true

(2)

HRandomDigraph10,20

HGraph 2: a directed graph with 10 vertices, 19 arc(s), and 1 self-loop(s)

(3)

JRandomDigraph4,6,weights=1..4

JGraph 3: a directed weighted graph with 4 vertices, 3 arc(s), and 3 self-loop(s)

(4)

WeightMatrixJ

0400022000330002

(5)

See Also

AssignEdgeWeights

GraphTheory:-IsDirected

GraphTheory:-WeightMatrix

RandomBipartiteGraph

RandomGraph

RandomNetwork

RandomTournament

RandomTree