Skip to content

PathGraph ​

A path graph — vertices joined in a line.

PathGraph(vertices)a path along vertices, in the order given — Wolfram's own (and only) form.
PathGraph(n)the path 1−2−⋯−n1 - 2 - \dots - n — our own convenience extension.
Typed signatures
TypePackageApplies
(any) -> valuecombinatoricsalways

Domain: Collections

Details
  • PathGraph(n) is a convenience this library adds; PathGraph[3] is an ERROR in real Wolfram (kernel-verified) — it only accepts a vertex list. Both forms are accepted here, but the Wolfram transpiler treats the whole head as foreign (its own context, not a plain rename) since it cannot tell the two call shapes apart — see FOREIGN in @enumeratio/wolfram.

Examples

Basic #

A 5-vertex path — the ends have degree 1

live ↗
InVertexDegree(PathGraph(5))\mathrm{VertexDegree}(\mathrm{PathGraph}(5))Out[1,2,2,2,1]\bigl\lbrack1, 2, 2, 2, 1\bigr\rbrack

A path along named vertices

live ↗
InPathGraph([a,b,c])\mathrm{PathGraph}(\bigl\lbrack a, b, c\bigr\rbrack)OutGraph([a,b,c],[UndirectedEdge(a,b),UndirectedEdge(b,c)])\mathrm{Graph}(\bigl\lbrack a, b, c\bigr\rbrack, \bigl\lbrack\mathrm{UndirectedEdge}(a, b), \mathrm{UndirectedEdge}(b, c)\bigr\rbrack)
About
Examples2

Implementation

mappedwolframpackages/oracle/src/mappings.ts

Real Wolfram's PathGraph takes a vertex list only -- our bare-integer form errors there (kernel-verified). Arity can't tell the two call shapes apart (both are arity 1), so the whole head is left unmapped rather than risk handing the kernel a call it rejects; see FOREIGN in @enumeratio/wolfram. Wolfram Function Repository searched; nothing that accepts both a bare vertex count and a vertex list under one name.

See also: CycleGraph, CompleteGraph