This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

PathGraphQ

PathGraphQ[g]
yields True if the graph g is a path and False otherwise.
  • 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.
Test whether a graph is a path:
The vertex degree is at most 2:
A complete graph is not a path:
The vertex degree is greater than 2:
Test whether a graph is a path:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
The vertex degree is at most 2:
In[3]:=
Click for copyable input
Out[3]=
 
A complete graph is not a path:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
The vertex degree is greater than 2:
In[3]:=
Click for copyable input
Out[3]=
Test undirected and directed graphs:
PathGraphQ gives False for anything that is not a path graph:
Test large graphs:
A path graph is loop-free if it has more than one vertex:
A one-vertex path graph can have a loop:
A path graph does not necessarily have edges:
Or vertices:
A path graph that starts and ends in the same vertex is a cycle graph:
A path graph with no repeated vertices is a tree:
An acyclic path graph is simple:
And also bipartite:
GridGraph are all path graphs:
A path graph is connected and each vertex has at most degree 2:
The line graph of a path is isomorphic to :
PathGraphQ gives False for non-explicit graphs:
New in 8