 MakeWeighted - Maple Help

GraphTheory

 MakeWeighted
 make weighted graph Calling Sequence MakeWeighted(G) MakeWeighted(G, M) MakeWeighted(G, opts) Parameters

 G - unweighted graph M - (optional) Matrix opts - (optional) one or more options as described below Options

 • metric = positive number or one of the symbols Euclidean, Manhattan, discrete, geographical, or infinity.
 The parameter metric must be a positive number or one of the symbols listed above. This specifies the metric to be used in computing distances when the option vertexpositions is set to a non-default value.
 When metric=geographical, the vertex positions must be 2-D and are interpreted as geographical positions on the Earth given as latitudes and longitudes in degrees. Entries in the weight matrix correspond to the distance between points in kilometers.
 The default metric is 2, the metric induced by the Euclidean norm.
 • norm = positive real or one of Euclidean, Manhattan, or infinity.
 An alias for the metric option.
 • vertexpositions=truefalse, Matrix, Array, or listlist
 When set to true or a list, Array, or Matrix, this specifies that the edge weights in the output graph should correspond to the geometric distances between the vertex positions in a particular layout. The metric used in computing these distances is controlled by the metric option.
 When a Matrix, Array, or list is provided corresponding to a set of 2-D or 3-D points, this is taken to specify the positions of the vertices in vertex order.
 When vertexpositions=true, any existing vertex positions stored in G are used, if they exist.
 When vertexpositions=false, the edge weights from the from the specified matrix M are used. If no such matrix M is provided, all weights between connected vertices are taken to be 1. This is the default. Description

 • The MakeWeighted command returns a graph with vertices and edges from G. If M is part of the input, then the edge weights are taken from it; otherwise edge weights are assumed to be 1. If G is undirected, then M is assumed to be a symmetric matrix.
 • For efficiency, use datatype=integer for wordsize integer weights and datatype=float for numerical (decimal) edge weights.
 • To read or modify the edge weights of a weighted graph, use the GetEdgeWeight and SetEdgeWeight commands. Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{Graph}\left(\left\{\left\{1,2\right\},\left\{2,3\right\},\left\{3,1\right\}\right\}\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected graph with 3 vertices and 3 edge\left(s\right)}}$ (1)
 > $M≔\mathrm{Matrix}\left(\left[\left[0,2,3\right],\left[2,0,1\right],\left[3,1,0\right]\right]\right)$
 ${M}{≔}\left[\begin{array}{ccc}{0}& {2}& {3}\\ {2}& {0}& {1}\\ {3}& {1}& {0}\end{array}\right]$ (2)
 > $\mathrm{H1}≔\mathrm{MakeWeighted}\left(G,M\right)$
 ${\mathrm{H1}}{≔}{\mathrm{Graph 2: an undirected weighted graph with 3 vertices and 3 edge\left(s\right)}}$ (3)
 > $\mathrm{Edges}\left(\mathrm{H1}\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{3}\right\}{,}\left\{{2}{,}{3}\right\}\right\}$ (4)
 > $\mathrm{WeightMatrix}\left(\mathrm{H1}\right)$
 $\left[\begin{array}{ccc}{0}& {2}& {3}\\ {2}& {0}& {1}\\ {3}& {1}& {0}\end{array}\right]$ (5)
 > $M≔\mathrm{Matrix}\left(M,\mathrm{datatype}={\mathrm{float}}_{8},\mathrm{shape}=\mathrm{symmetric}\right)$
 ${M}{≔}\left[\begin{array}{ccc}{0.}& {2.}& {3.}\\ {2.}& {0.}& {1.}\\ {3.}& {1.}& {0.}\end{array}\right]$ (6)
 > $\mathrm{H2}≔\mathrm{MakeWeighted}\left(G,M\right)$
 ${\mathrm{H2}}{≔}{\mathrm{Graph 3: an undirected weighted graph with 3 vertices and 3 edge\left(s\right)}}$ (7)
 > $\mathrm{WeightMatrix}\left(\mathrm{H2}\right)$
 $\left[\begin{array}{ccc}{0.}& {2.}& {3.}\\ {2.}& {0.}& {1.}\\ {3.}& {1.}& {0.}\end{array}\right]$ (8) Compatibility

 • The GraphTheory[MakeWeighted] command was updated in Maple 2023.
 • The metric, norm and vertexpositions options were introduced in Maple 2023.