GraphTheory
SetEdgeWeight
set edge weight
GetEdgeWeight
get edge weight
Calling Sequence
Parameters
Description
Examples
SetEdgeWeight(G, e, w)
GetEdgeWeight(G, e)
G
-
weighted graph
e
edge/arc
w
numeric; edge weight
SetEdgeWeight is used to change the weight of an edge of a weighted graph. It returns the old weight of the edge.
GetEdgeWeight is used to get the weight of an edge of a weighted graph.
with⁡GraphTheory:
G≔MakeWeighted⁡CompleteGraph⁡4
G≔Graph 1: an undirected weighted graph with 4 vertices and 6 edge(s)
GetEdgeWeight⁡G,1,2
1
SetEdgeWeight⁡G,1,2,3
3
foreinEdges⁡CycleGraph⁡4doSetEdgeWeight⁡G,e,2enddo
WeightMatrix⁡G
0212202112022120
See Also
IsWeighted
MakeWeighted
WeightMatrix
Download Help Document
What kind of issue would you like to report? (Optional)