WLJS LogoWLJS Notebook

PathGraph

PathGraph[{v1, v2, ...}] creates a path graph connecting vertices in sequence.

Examples

Create a path graph:

PathGraph[{1, 2, 3, 4, 5}]
(* Path: 1-2-3-4-5 *)

Named vertices:

PathGraph[{"A", "B", "C", "D"}, VertexLabels -> "Name"]

Path length:

EdgeCount[PathGraph[Range[10]]]
(* 9 *)

Please visit the official Wolfram Language Reference for more details.

On this page