RandomNetwork - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


GraphTheory[RandomGraphs]

  

RandomNetwork

  

generate a random network

 

Calling Sequence

Parameters

Options

Description

Examples

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

-

numeric value between 0.0 and 1.0

V

-

list of vertices

q

-

numeric value between 0.0 and 1.0

options

-

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

Options

• 

acyclic = truefalse

  

If the option acyclic is specified, a random acyclic network is created.

• 

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 procedure

  

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

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.

• 

You can optionally specify q which is a numeric value 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.

• 

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

Examples

withGraphTheory:

withRandomGraphs:

NRandomNetwork10,0.5

NGraph 1: a directed graph with 10 vertices and 28 arc(s)

(1)

IsNetworkN

1,10

(2)

DrawGraphN

NRandomNetworka,b,c,d,e,0.5,acyclic

NGraph 2: a directed graph with 5 vertices and 6 arc(s)

(3)

DrawNetworkN

NRandomNetwork10,0.2,acyclic,weights=1..5

NGraph 3: a directed weighted graph with 10 vertices and 31 arc(s)

(4)

WeightMatrixN

0100000000003132223000012010200000412024000001131400000052340000000025000000004200000000040000000000

(5)

MaxFlowN,1,10

1,0100000000001000000000010000000000100000000001000000000010000000000010000000000000000000010000000000

(6)

See Also

AssignEdgeWeights

GraphTheory:-DrawGraph

GraphTheory:-DrawNetwork

GraphTheory:-IsNetwork

GraphTheory:-MaxFlow

RandomBipartiteGraph

RandomDigraph

RandomGraph

RandomTournament

RandomTree

 


Download Help Document