GetEdgeWeight - Maple Help

GraphTheory

 GetEdgeWeight
 get edge weight
 SetEdgeWeight
 set edge weight
 GetEdgeWeights
 get multiple edge weights
 SetEdgeWeights
 set multiple edge weights

 Calling Sequence GetEdgeWeight(G, e) SetEdgeWeight(G, e, w) GetEdgeWeights(G, edges) SetEdgeWeights(G, eqs)

Parameters

 G - weighted graph e - edge/arc w - numeric; edge weight edges - list or set of edges/arcs eqs - list or set of equations of the form edge/arc = numeric

Description

 • GetEdgeWeight returns the weight of an edge of a weighted graph.
 • SetEdgeWeight updates the weight of an edge of a weighted graph. It returns the old weight of the edge.
 • GetEdgeWeights(G, edges) accepts a list or set edges and returns a list or set of the corresponding edge weights.
 • SetEdgeWeights(G, eqs) accepts a list or set eqs of equations whose left-hand side is an edge and whose right-hand side is a weight. It updates the edge weights in G correspondingly.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{MakeWeighted}\left(\mathrm{CompleteGraph}\left(4\right)\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected weighted graph with 4 vertices and 6 edge\left(s\right)}}$ (1)
 > $\mathrm{GetEdgeWeight}\left(G,\left\{1,2\right\}\right)$
 ${1}$ (2)
 > $\mathrm{SetEdgeWeight}\left(G,\left\{1,2\right\},3\right)$
 ${1}$ (3)
 > $\mathrm{GetEdgeWeight}\left(G,\left\{1,2\right\}\right)$
 ${3}$ (4)
 > $\mathbf{for}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}e\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{Edges}\left(\mathrm{CycleGraph}\left(4\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{SetEdgeWeight}\left(G,e,2\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end do}$
 ${1}$ (5)
 > $\mathrm{WeightMatrix}\left(G\right)$
 $\left[\begin{array}{cccc}{0}& {2}& {1}& {2}\\ {2}& {0}& {2}& {1}\\ {1}& {2}& {0}& {2}\\ {2}& {1}& {2}& {0}\end{array}\right]$ (6)

Compatibility

 • The GraphTheory[GetEdgeWeights] and GraphTheory[SetEdgeWeights] commands were introduced in Maple 2023.