PathGraphCopy to clipboard.
✖
PathGraph
Details and Options

- PathGraph generates a Graph object.
- PathGraph supports the same vertices, edges, wrappers, and options as Graph.
- An undirected path graph is a connected graph where each vertex has at most degree two.
- A directed path graph is a connected graph where each vertex has at most in-degree one and at most out-degree one.
- PathGraph can only represent self-avoiding paths, except for cycles.
-
AlignmentPoint Center the default point in the graphic to align with AnnotationRules {} annotations for graph, edges and vertices AspectRatio Automatic ratio of height to width Axes False whether to draw axes AxesLabel None axes labels AxesOrigin Automatic where axes should cross AxesStyle {} style specifications for the axes Background None background color for the plot BaselinePosition Automatic how to align with a surrounding text baseline BaseStyle {} base style specifications for the graphic ContentSelectable Automatic whether to allow contents to be selected CoordinatesToolOptions Automatic detailed behavior of the coordinates tool DirectedEdges Automatic whether to interpret Rule as DirectedEdge EdgeLabels None labels and label placements for edges EdgeLabelStyle Automatic style to use for edge labels EdgeShapeFunction Automatic generate graphic shapes for edges EdgeStyle Automatic style used for edges EdgeWeight Automatic weights for edges Epilog {} primitives rendered after the main plot FormatType TraditionalForm the default format type for text Frame False whether to put a frame around the plot FrameLabel None frame labels FrameStyle {} style specifications for the frame FrameTicks Automatic frame ticks FrameTicksStyle {} style specifications for frame ticks GraphHighlight {} graph elements to highlight GraphHighlightStyle Automatic style for highlight GraphLayout Automatic how to lay out vertices and edges GridLines None grid lines to draw GridLinesStyle {} style specifications for grid lines ImageMargins 0. the margins to leave around the graphic ImagePadding All what extra padding to allow for labels etc. ImageSize Automatic the absolute size at which to render the graphic LabelStyle {} style specifications for labels Method Automatic details of graphics methods to use PerformanceGoal Automatic aspects of performance to try to optimize PlotLabel None an overall label for the plot PlotRange All range of values to include PlotRangeClipping False whether to clip at the plot range PlotRangePadding Automatic how much to pad the range of values PlotRegion Automatic the final display region to be filled PlotTheme $PlotTheme overall theme for the graph PreserveImageOptions Automatic whether to preserve image options when displaying new versions of the same graphic Prolog {} primitives rendered before the main plot RotateLabel True whether to rotate y labels on the frame Ticks Automatic axes ticks TicksStyle {} style specifications for axes ticks VertexCoordinates Automatic coordinates for vertices VertexLabels None labels and placements for vertices VertexLabelStyle Automatic style to use for vertex labels VertexShape Automatic graphic shape for vertices VertexShapeFunction Automatic generate graphic shapes for vertices VertexSize Medium size of vertices VertexStyle Automatic styles for vertices VertexWeight Automatic weights for vertices


List of all options




Examples
open allclose allBasic Examples (2)Summary of the most common use cases
A path constructed from a list of vertices:

https://wolfram.com/xid/0j42amje-e7vmae


https://wolfram.com/xid/0j42amje-e0uc28


https://wolfram.com/xid/0j42amje-vgkjr

Scope (6)Survey of the scope of standard use cases
Connectivity (6)
Create an undirected graph using characters, entering the character as ue
:

https://wolfram.com/xid/0j42amje-eyabqs

Create a directed graph using characters, entering the character as de
:

https://wolfram.com/xid/0j42amje-h2znzh

Create a directed graph from a list of rules:

https://wolfram.com/xid/0j42amje-t8xwn

Create an undirected graph from a list of rules:

https://wolfram.com/xid/0j42amje-dwwk49

Use VertexList and EdgeList to get vertices and edges:

https://wolfram.com/xid/0j42amje-z3ycv

The ordering for edges is the order in which they were entered:

https://wolfram.com/xid/0j42amje-c60esi

The ordering for vertices is the order in which they entered in the edges:

https://wolfram.com/xid/0j42amje-cs08co

Use an explicit vertex list to control the ordering used by VertexList:

https://wolfram.com/xid/0j42amje-cwwd2i

The input vertex list controls the resulting vertex order:

https://wolfram.com/xid/0j42amje-edo3i

Any expression can be used as vertices:

https://wolfram.com/xid/0j42amje-ekr9p8


https://wolfram.com/xid/0j42amje-ezslu6

Options (82)Common values & functionality for each option
AnnotationRules (3)
Specify an annotation for vertices:

https://wolfram.com/xid/0j42amje-bugzer


https://wolfram.com/xid/0j42amje-uk5apf


https://wolfram.com/xid/0j42amje-34likd


https://wolfram.com/xid/0j42amje-fits1l

DirectedEdges (2)
By default, a directed path is generated when giving a list of rules:

https://wolfram.com/xid/0j42amje-iwq8nh

Use DirectedEdges->False to interpret rules as undirected edges:

https://wolfram.com/xid/0j42amje-hsbm48

Use DirectedEdge or UndirectedEdge to directly specify whether a graph is directed or not:

https://wolfram.com/xid/0j42amje-c4p2v7

EdgeLabels (7)

https://wolfram.com/xid/0j42amje-z5279


https://wolfram.com/xid/0j42amje-1t3zd

https://wolfram.com/xid/0j42amje-hr4015

Use any expression as a label:

https://wolfram.com/xid/0j42amje-b7zkda

Use Placed with symbolic locations to control label placement along an edge:

https://wolfram.com/xid/0j42amje-fnltmw

Use explicit coordinates to place labels:

https://wolfram.com/xid/0j42amje-ndfa94

Vary positions within the label:

https://wolfram.com/xid/0j42amje-bg84f5

Place multiple labels using Placed in a wrapper:

https://wolfram.com/xid/0j42amje-cj2dt

Any number of labels can be used:

https://wolfram.com/xid/0j42amje-dy5run

Place multiple labels using EdgeLabels:

https://wolfram.com/xid/0j42amje-33q72

Use automatic labeling by values through Tooltip and StatusArea:

https://wolfram.com/xid/0j42amje-dhn5kr


https://wolfram.com/xid/0j42amje-bd54a9

EdgeShapeFunction (6)
Get a list of built-in settings for EdgeShapeFunction:

https://wolfram.com/xid/0j42amje-hfmhqu

Undirected edges including the basic line:

https://wolfram.com/xid/0j42amje-fjhml

Lines with different glyphs on the edges:

https://wolfram.com/xid/0j42amje-lxjrsx

Directed edges including solid arrows:

https://wolfram.com/xid/0j42amje-lvr0ss


https://wolfram.com/xid/0j42amje-qslbt


https://wolfram.com/xid/0j42amje-f6ch7m

Specify an edge function for an individual edge:

https://wolfram.com/xid/0j42amje-eczrhp

Combine with a different default edge function:

https://wolfram.com/xid/0j42amje-jwjk2c

Draw edges by running a program:

https://wolfram.com/xid/0j42amje-j0dznf

https://wolfram.com/xid/0j42amje-lsgwlp

EdgeShapeFunction can be combined with EdgeStyle:

https://wolfram.com/xid/0j42amje-gt52v9

EdgeShapeFunction has higher priority than EdgeStyle:

https://wolfram.com/xid/0j42amje-cfn5oz

EdgeStyle (2)
EdgeWeight (2)
Specify a weight for all edges:

https://wolfram.com/xid/0j42amje-8fxi6


https://wolfram.com/xid/0j42amje-baprxk

Use any numeric expression as a weight:

https://wolfram.com/xid/0j42amje-bcptub


https://wolfram.com/xid/0j42amje-fibbsw

GraphHighlight (3)

https://wolfram.com/xid/0j42amje-t1013k


https://wolfram.com/xid/0j42amje-ewa020


https://wolfram.com/xid/0j42amje-bz747

GraphHighlightStyle (2)
Get a list of built-in settings for GraphHighlightStyle:

https://wolfram.com/xid/0j42amje-lu7p68

Use built-in settings for GraphHighlightStyle:

https://wolfram.com/xid/0j42amje-qwjuvn

GraphLayout (5)
By default, the layout is chosen automatically:

https://wolfram.com/xid/0j42amje-dbtrff

Specify layouts on special curves:

https://wolfram.com/xid/0j42amje-h6yv39

Specify layouts that satisfy optimality criteria:

https://wolfram.com/xid/0j42amje-6c5vg

VertexCoordinates overrides GraphLayout coordinates:

https://wolfram.com/xid/0j42amje-etquvf

Use AbsoluteOptions to extract VertexCoordinates computed using a layout algorithm:

https://wolfram.com/xid/0j42amje-qfc3w


https://wolfram.com/xid/0j42amje-gaec92

PlotTheme (4)
Base Themes (2)
VertexCoordinates (3)
By default, any vertex coordinates are computed automatically:

https://wolfram.com/xid/0j42amje-5spor

Extract the resulting vertex coordinates using AbsoluteOptions:

https://wolfram.com/xid/0j42amje-2whoh

Specify a layout function along an ellipse:

https://wolfram.com/xid/0j42amje-mwyuvu

https://wolfram.com/xid/0j42amje-cvx31k

Use it to generate vertex coordinates for a graph:

https://wolfram.com/xid/0j42amje-uukkr

VertexCoordinates has higher priority than GraphLayout:

https://wolfram.com/xid/0j42amje-hdij4u

VertexLabels (13)

https://wolfram.com/xid/0j42amje-c9ka50


https://wolfram.com/xid/0j42amje-i40mcj


https://wolfram.com/xid/0j42amje-whkpg

Use any expression as a label:

https://wolfram.com/xid/0j42amje-kokbex

Use Placed with symbolic locations to control label placement, including outside positions:

https://wolfram.com/xid/0j42amje-csc6y

Symbolic outside corner positions:

https://wolfram.com/xid/0j42amje-405x2

https://wolfram.com/xid/0j42amje-fjgxt8


https://wolfram.com/xid/0j42amje-fg0pin

Symbolic inside corner positions:

https://wolfram.com/xid/0j42amje-kfrv7

https://wolfram.com/xid/0j42amje-dr87wv

Use explicit coordinates to place the center of labels:

https://wolfram.com/xid/0j42amje-cqfi4r

Place all labels at the upper-right corner of the vertex and vary the coordinates within the label:

https://wolfram.com/xid/0j42amje-20sv

Place multiple labels using Placed in a wrapper:

https://wolfram.com/xid/0j42amje-eazh7z

Any number of labels can be used:

https://wolfram.com/xid/0j42amje-ftgvi6

Place multiple labels using VertexLabels:

https://wolfram.com/xid/0j42amje-kusfg3

Use the argument to Placed to control formatting including Tooltip:

https://wolfram.com/xid/0j42amje-cxzeiw

Or StatusArea:

https://wolfram.com/xid/0j42amje-nddwmk

Use more elaborate formatting functions:

https://wolfram.com/xid/0j42amje-bd9m40

https://wolfram.com/xid/0j42amje-cggp96


https://wolfram.com/xid/0j42amje-l3s7yb

https://wolfram.com/xid/0j42amje-cljxny


https://wolfram.com/xid/0j42amje-cqkdbb

https://wolfram.com/xid/0j42amje-bjoam1

VertexShape (5)
Use any Graphics, Image, or Graphics3D as a vertex shape:

https://wolfram.com/xid/0j42amje-dvz661

Specify vertex shapes for individual vertices:

https://wolfram.com/xid/0j42amje-i1s9c7

VertexShape can be combined with VertexSize:

https://wolfram.com/xid/0j42amje-gsg23u

VertexShape is not affected by VertexStyle:

https://wolfram.com/xid/0j42amje-3ef8f

VertexShapeFunction has higher priority than VertexShape:

https://wolfram.com/xid/0j42amje-budnxj

VertexShapeFunction (10)
Get a list of built-in collections for VertexShapeFunction:

https://wolfram.com/xid/0j42amje-cc7w4d

Use built-in settings for VertexShapeFunction in the "Basic" collection:

https://wolfram.com/xid/0j42amje-kqz1mq


https://wolfram.com/xid/0j42amje-hshluc


https://wolfram.com/xid/0j42amje-wm2s7

Use built-in settings for VertexShapeFunction in the "Rounded" collection:

https://wolfram.com/xid/0j42amje-je3pt2


https://wolfram.com/xid/0j42amje-cj5ftp

Use built-in settings for VertexShapeFunction in the "Concave" collection:

https://wolfram.com/xid/0j42amje-f4ea1p


https://wolfram.com/xid/0j42amje-bfhgv4


https://wolfram.com/xid/0j42amje-fhb0zi

Combine with a default vertex function:

https://wolfram.com/xid/0j42amje-fmawhn

Draw vertices using a predefined graphic:

https://wolfram.com/xid/0j42amje-6fiu

Draw vertices by running a program:

https://wolfram.com/xid/0j42amje-oroxkx

https://wolfram.com/xid/0j42amje-lt54lp

VertexShapeFunction can be combined with VertexStyle:

https://wolfram.com/xid/0j42amje-c5uihz

https://wolfram.com/xid/0j42amje-djz15m

VertexShapeFunction has higher priority than VertexStyle:

https://wolfram.com/xid/0j42amje-h9wrh2

https://wolfram.com/xid/0j42amje-ir0ry

VertexShapeFunction can be combined with VertexSize:

https://wolfram.com/xid/0j42amje-0wy12

VertexShapeFunction has higher priority than VertexShape:

https://wolfram.com/xid/0j42amje-lnnzsy

VertexSize (8)
By default, the size of vertices is computed automatically:

https://wolfram.com/xid/0j42amje-dsy1ve

Specify the size of all vertices using symbolic vertex size:

https://wolfram.com/xid/0j42amje-lskxsr

Use a fraction of the minimum distance between vertex coordinates:

https://wolfram.com/xid/0j42amje-3lxk1

Use a fraction of the overall diagonal for all vertex coordinates:

https://wolfram.com/xid/0j42amje-my5omo

Specify size in both the and
directions:

https://wolfram.com/xid/0j42amje-c7twgs

Specify a size for individual vertices:

https://wolfram.com/xid/0j42amje-h6r4ja

VertexSize can be combined with VertexShapeFunction:

https://wolfram.com/xid/0j42amje-b3jw4t

VertexSize can be combined with VertexShape:

https://wolfram.com/xid/0j42amje-dego1v

VertexStyle (5)

https://wolfram.com/xid/0j42amje-ehbi7i


https://wolfram.com/xid/0j42amje-dtkst6

VertexShapeFunction can be combined with VertexStyle:

https://wolfram.com/xid/0j42amje-om30z

https://wolfram.com/xid/0j42amje-nnfnwx

VertexShapeFunction has higher priority than VertexStyle:

https://wolfram.com/xid/0j42amje-kfv4n

https://wolfram.com/xid/0j42amje-cldcke

VertexStyle can be combined with BaseStyle:

https://wolfram.com/xid/0j42amje-bby1h9

VertexStyle has higher priority than BaseStyle:

https://wolfram.com/xid/0j42amje-d0df6

VertexShape is not affected by VertexStyle:

https://wolfram.com/xid/0j42amje-3rqw0

VertexWeight (2)
Set the weight for all vertices:

https://wolfram.com/xid/0j42amje-coy9ti


https://wolfram.com/xid/0j42amje-jjkrix

Use any numeric expression as a weight:

https://wolfram.com/xid/0j42amje-lxjpz1


https://wolfram.com/xid/0j42amje-jleavv

Applications (6)Sample problems that can be solved with this function
The GraphCenter of path graphs:

https://wolfram.com/xid/0j42amje-c1bjjo

The GraphPeriphery:

https://wolfram.com/xid/0j42amje-oczo41

The VertexEccentricity:

https://wolfram.com/xid/0j42amje-b61b5b

Highlight the vertex eccentricity path:

https://wolfram.com/xid/0j42amje-dsdipl

https://wolfram.com/xid/0j42amje-bqnfgg

The GraphRadius:

https://wolfram.com/xid/0j42amje-ilrtl


https://wolfram.com/xid/0j42amje-lyxd43

https://wolfram.com/xid/0j42amje-hisghw

The GraphDiameter:

https://wolfram.com/xid/0j42amje-li5jze


https://wolfram.com/xid/0j42amje-h2qy47

https://wolfram.com/xid/0j42amje-deasqu

Visualize different centralities for PathGraph:

https://wolfram.com/xid/0j42amje-evoqpn

https://wolfram.com/xid/0j42amje-baipzx

https://wolfram.com/xid/0j42amje-cuusur

Highlight the closeness centrality:

https://wolfram.com/xid/0j42amje-m8ecv

Highlight the eigenvector centrality:

https://wolfram.com/xid/0j42amje-c6qxsb

Properties & Relations (10)Properties of the function, and connections to other functions
Use VertexCount and EdgeCount to count vertices and edges:

https://wolfram.com/xid/0j42amje-ewldet


https://wolfram.com/xid/0j42amje-buy2ca

Use VertexList and EdgeList to enumerate vertices and edges in standard order:

https://wolfram.com/xid/0j42amje-l0u8q

https://wolfram.com/xid/0j42amje-l06m

Edges and vertices are given in the order they are input:

https://wolfram.com/xid/0j42amje-chydq0

https://wolfram.com/xid/0j42amje-f3ry1t


https://wolfram.com/xid/0j42amje-ctjma3

https://wolfram.com/xid/0j42amje-tgvla

Rows and columns of the adjacency matrix follow the order given by VertexList:

https://wolfram.com/xid/0j42amje-bil8h7

https://wolfram.com/xid/0j42amje-j52iu2


https://wolfram.com/xid/0j42amje-i573me

Compute the IncidenceMatrix from a graph:

https://wolfram.com/xid/0j42amje-bkkim5

https://wolfram.com/xid/0j42amje-oha81q
The row ordering is given by VertexList and column ordering is given by EdgeList:

https://wolfram.com/xid/0j42amje-vd1rm


https://wolfram.com/xid/0j42amje-cdhx8l

A path graph is a loop-free graph:

https://wolfram.com/xid/0j42amje-roqnm


https://wolfram.com/xid/0j42amje-g0013

A path graph that starts and ends in the same vertex is a cycle graph:

https://wolfram.com/xid/0j42amje-elsy02


https://wolfram.com/xid/0j42amje-bzbx5p

A path graph is connected and each vertex has at most degree 2:

https://wolfram.com/xid/0j42amje-cvi52e


https://wolfram.com/xid/0j42amje-dn4w0f


https://wolfram.com/xid/0j42amje-gh1tvf

A path graph with no repeated vertices is a tree:

https://wolfram.com/xid/0j42amje-j4l391

A path graph with no repeated vertices is acyclic:

https://wolfram.com/xid/0j42amje-d0zsa7


https://wolfram.com/xid/0j42amje-nfykd6

The line graph of a path is isomorphic to
:

https://wolfram.com/xid/0j42amje-e93bcs


https://wolfram.com/xid/0j42amje-pgrp8


https://wolfram.com/xid/0j42amje-elfvf1

Wolfram Research (2010), PathGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/PathGraph.html (updated 2015).
Text
Wolfram Research (2010), PathGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/PathGraph.html (updated 2015).
Wolfram Research (2010), PathGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/PathGraph.html (updated 2015).
CMS
Wolfram Language. 2010. "PathGraph." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/PathGraph.html.
Wolfram Language. 2010. "PathGraph." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/PathGraph.html.
APA
Wolfram Language. (2010). PathGraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PathGraph.html
Wolfram Language. (2010). PathGraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PathGraph.html
BibTeX
@misc{reference.wolfram_2025_pathgraph, author="Wolfram Research", title="{PathGraph}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/PathGraph.html}", note=[Accessed: 29-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_pathgraph, organization={Wolfram Research}, title={PathGraph}, year={2015}, url={https://reference.wolfram.com/language/ref/PathGraph.html}, note=[Accessed: 29-March-2025
]}