GraphTheory
PathWeight
compute path weight
Calling Sequence
Parameters
Description
Examples
Compatibility
PathWeight(G, w)
G
-
graph
w
list or Trail object corresponding to a walk in the graph
The PathWeight(G) command returns the path weight of the walk w in the graph G.
When G is weighted, this is the sum of the edge weights for all edges appearing in the walk w.
When G is unweighted, this is simply the number of edges of the walk.
Note that self-loops appearing in w are not included in the edge count for the purposes of computing graph density.
Compute the path weight of a walk through an unweighted graph.
with⁡GraphTheory:
K4≔CompleteGraph⁡4
K4≔Graph 1: an undirected graph with 4 vertices and 6 edge(s)
PathWeight⁡K4,1,2,3,4
4
Compute the path weight of a walk through a weighted directed graph including a self-loop.
GS≔Graph⁡3,Matrix⁡3,0,2,3,2,0,4,5,3,3
GS≔Graph 2: a directed weighted graph with 3 vertices, 6 arc(s), and 1 self-loop(s)
PathWeight⁡GS,Trail⁡1,2,3,3,1
14
BavarianCities≔Import⁡example/bayern10.csv,base=datadir,output=Matrix
BavarianCities≔München48.13722211.575556Nürnberg49.45555611.078611Augsburg48.37166710.898333Regensburg49.01722212.096944Ingolstadt48.7641511.42434Würzburg49.794419.92937Fürth49.477410.98844Erlangen49.59636111.004311Bamberg49.89166710.891667Bayreuth49.947511.5775
G1≔GraphTheory:-CompleteGraph⁡convert⁡BavarianCities..,1,list,vertexpositions=BavarianCities..,2..3
G1≔Graph 3: an undirected graph with 10 vertices and 45 edge(s)
G2≔MakeWeighted⁡G1,vertexpositions,metric=Euclidean
G2≔Graph 4: an undirected weighted graph with 10 vertices and 45 edge(s)
PathWeight⁡G2,M303274nchen,Regensburg,Bayreuth,Bamberg,Erlangen,W303274rzburg,F303274rth,N303274rnberg,Ingolstadt,Augsburg,M303274nchen
7.52978991560743
The GraphTheory[PathWeight] command was introduced in Maple 2023.
For more information on Maple 2023 changes, see Updates in Maple 2023.
See Also
NumberOfEdges
Download Help Document