PathGraphQ

PathGraphQ[g]

yields True if the graph g is a path and False otherwise.

Details

  • 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.

Examples

open allclose all

Basic Examples  (2)

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:

Scope  (6)

PathGraphQ works with undirected graphs:

Directed graphs:

Multigraphs:

Mixed graphs:

PathGraphQ gives False for anything that is not a path graph:

Test large graphs:

Properties & Relations  (8)

A path graph is loop-free if it has more than one vertex:

A path graph does not necessarily have edges:

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[{1,,1,k,1,,1}] 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 :

Possible Issues  (1)

PathGraphQ gives False for non-explicit graphs:

Introduced in 2010
 (8.0)