GraphTheory[RandomGraphs] - Maple Help

Online Help

All Products    Maple    MapleSim


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

GraphTheory[RandomGraphs]

  

RandomTree

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

RandomTree(n)

RandomTree(n,degree<d)

RandomTree(n,options)

Parameters

n

-

positive integer or list of vertex labels

d

-

positive integer

options

-

sequence of options (see below)

Description

• 

The RandomTree(n)  command creates a random tree on n vertices. This is an undirected connected graph with n-1 edges. If the first input n is a positive integer, the vertices are labeled 1,2,...,n. Alternatively you may specify the vertex labels in a list.

• 

Starting with the empty undirected graph T on n vertices, edges are chosen uniformly at random and inserted into T if they do do not create a cycle.  This is repeated until T has n-1 edges.

• 

The option degree<d or degree<=d limits the maximum degree of every vertex in the tree.

• 

If the option weights=m..n is specified, where m <= n are integers, the tree 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 tree 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 tree 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

withGraphTheory&colon;

withRandomGraphs&colon;

TRandomTree10

T:=Graph 1: an undirected unweighted graph with 10 vertices and 9 edge(s)

(1)

TRandomTree10&comma;weights&equals;1..9

T:=Graph 2: an undirected weighted graph with 10 vertices and 9 edge(s)

(2)

IsTreeT

true

(3)

WeightMatrixT

0080080000000000000780003068090000000100003000000080000000000060000000008100000000000000070790000070

(4)

TRandomTree100

T:=Graph 3: an undirected unweighted graph with 100 vertices and 99 edge(s)

(5)

MaximumDegreeT

6

(6)

TRandomTree100&comma;degree<4

T:=Graph 4: an undirected unweighted graph with 100 vertices and 99 edge(s)

(7)

MaximumDegreeT

3

(8)

See Also

AssignEdgeWeights

GraphTheory[IsTree]

GraphTheory[WeightMatrix]

RandomBipartiteGraph

RandomDigraph

RandomGraph

RandomNetwork

RandomTournament

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam