GraphTheory[RandomGraphs] - Maple Help

Online Help

All Products    Maple    MapleSim


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

GraphTheory[RandomGraphs]

  

AssignEdgeWeights

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

AssignEdgeWeights(G,m..n)

AssignEdgeWeights(G,a..b)

AssignEdgeWeights(G,R)

Parameters

G

-

graph

m, n

-

integers satisfying n >= m

a, b

-

floats satisfying b >= a

R

-

user defined function for generating random edge weights

Description

• 

If G is a weighted graph, AssignEdgeWeights(G,...) assigns new random edge weights to G, i.e., for each edge (i,j) in G the (i,j)'th entry in the weight matrix of G is updated inplace.

• 

If G is an unweighted graph, a weighted graph is first created before assigning the edge weights.  The structure of G is not copied.

• 

AssignEdgeWeights(G,m..n) assigns the edges of the weighted graph random integer weights uniformly distributed on [m,n].

• 

AssignEdgeWeights(G,a..b) assigns the edges of the weighted graph random decimal weights uniformly distributed on [a,b).

• 

AssignEdgeWeights(G,R) assigns the edges of the weighted graph G values defined by R().  The Maple procedure R must return numerical values, i.e., integers, rationals, or floating point constants.

• 

The random number generator used to compute the edge weights can be seeded using the randomize function.

Examples

withGraphTheory:

withRandomGraphs:

TGraphweighted,1,2,2,3,3,4,4,1

T:=Graph 1: a directed weighted graph with 4 vertices and 4 arc(s)

(1)

WeightMatrixT

0100001000011000

(2)

AssignEdgeWeightsT,1..9

Graph 1: a directed weighted graph with 4 vertices and 4 arc(s)

(3)

WeightMatrixT

0400001000071000

(4)

TRandomTree4

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

(5)

TAssignEdgeWeightsT,0.0..1.0

T:=Graph 3: an undirected weighted graph with 4 vertices and 3 edge(s)

(6)

WWeightMatrixT

W:=0.0.0.0.9575068354342980.0.0.5468815192049840.2784982188670480.0.5468815192049840.0.0.9575068354342980.2784982188670480.0.

(7)

op3,W

datatype=float8,storage=rectangular,order=Fortran_order,shape=symmetric

(8)

TRandomTree100

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

(9)

TAssignEdgeWeightsT,1..99

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

(10)

op3,WeightMatrixT

datatype=integer,storage=sparse,order=Fortran_order,shape=symmetric

(11)

This example creates a network

NGraph1,2,1,3,1,4,2,3,4,3,2,5,3,5,4,5

N:=Graph 6: a directed unweighted graph with 5 vertices and 8 arc(s)

(12)

Urand1..4:

B := proc() if U()=1 then 1 else 2 fi end:

So Prob(B=1)=1/4, Prob(B=2)=3/4

NAssignEdgeWeightsN,B

N:=Graph 7: a directed weighted graph with 5 vertices and 8 arc(s)

(13)

WWeightMatrixN

W:=0222000202000020010200000

(14)

op3,W

datatype=anything,storage=rectangular,order=Fortran_order,shape=

(15)

See Also

GraphTheory[Graph]

GraphTheory[MakeWeighted]

GraphTheory[WeightMatrix]

RandomTree

 


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