generate random edge weights for a graph
integers satisfying m≤n
floats satisfying a≤b
user-defined function for generating random edge weights
If G is a weighted graph, AssignEdgeWeights(G,...) assigns new random edge weights to G, that is, 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, that is, integers, rationals, or floating-point constants.
The random number generator used to compute the edge weights can be seeded using the seed option or the randomize function.
T≔Graph 1: a directed weighted graph with 4 vertices and 4 arc(s)
Graph 1: a directed weighted graph with 4 vertices and 4 arc(s)
T≔Graph 2: an undirected unweighted graph with 4 vertices and 3 edge(s)
T≔Graph 3: an undirected weighted graph with 4 vertices and 3 edge(s)
T≔Graph 4: an undirected unweighted graph with 100 vertices and 99 edge(s)
T≔Graph 5: an undirected weighted graph with 100 vertices and 99 edge(s)
This example creates a network
N≔Graph 6: a directed unweighted graph with 5 vertices and 8 arc(s)
B := proc() if U()=1 then 1 else 2 end if; end proc:
So Prob(B=1)=1/4, Prob(B=2)=3/4
N≔Graph 7: a directed weighted graph with 5 vertices and 8 arc(s)
Download Help Document
What kind of issue would you like to report? (Optional)