GraphTheory/PathWeight - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : GraphTheory/PathWeight

GraphTheory

  

PathWeight

  

compute path weight

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

PathWeight(G, w)

Parameters

G

-

graph

w

-

list or Trail object corresponding to a walk in the graph

Description

• 

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.

Examples

Compute the path weight of a walk through an unweighted graph.

withGraphTheory:

K4CompleteGraph4

K4Graph 1: an undirected graph with 4 vertices and 6 edge(s)

(1)

PathWeightK4,1,2,3,4

4

(2)

Compute the path weight of a walk through a weighted directed graph including a self-loop.

GSGraph3,Matrix3,0,2,3,2,0,4,5,3,3

GSGraph 2: a directed weighted graph with 3 vertices, 6 arc(s), and 1 self-loop(s)

(3)

PathWeightGS,Trail1,2,3,3,1

14

(4)

BavarianCitiesImportexample/bayern10.csv,base=datadir,output=Matrix

BavarianCitiesMünchen48.13722211.575556Nürnberg49.45555611.078611Augsburg48.37166710.898333Regensburg49.01722212.096944Ingolstadt48.7641511.42434Würzburg49.794419.92937Fürth49.477410.98844Erlangen49.59636111.004311Bamberg49.89166710.891667Bayreuth49.947511.5775

(5)

G1GraphTheory:-CompleteGraphconvertBavarianCities..,1,list,vertexpositions=BavarianCities..,2..3

G1Graph 3: an undirected graph with 10 vertices and 45 edge(s)

(6)

G2MakeWeightedG1,vertexpositions,metric=Euclidean

G2Graph 4: an undirected weighted graph with 10 vertices and 45 edge(s)

(7)

PathWeightG2,M303274nchen,Regensburg,Bayreuth,Bamberg,Erlangen,W303274rzburg,F303274rth,N303274rnberg,Ingolstadt,Augsburg,M303274nchen

7.52978991560743

(8)

Compatibility

• 

The GraphTheory[PathWeight] command was introduced in Maple 2023.

• 

For more information on Maple 2023 changes, see Updates in Maple 2023.

See Also

NumberOfEdges