TreeGraphQ

TreeGraphQ[g]

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

Details

  • A tree is a connected graph with no cycles.

Examples

open allclose all

Basic Examples  (2)

Test whether a graph is a tree:

A graph with cycles is not a tree:

Scope  (6)

TreeGraphQ works with undirected graphs:

Directed graphs:

Multigraphs:

Mixed graphs:

TreeGraphQ gives False for anything that is not a tree graph:

TreeGraphQ works with large graphs:

Properties & Relations  (10)

A tree graph can be a simple graph:

A tree graph can be a weighted graph:

A star is a special tree with as many leaves as possible:

A path graph with no repeated vertices is a tree with two leaves:

A graph with self-loops is not a tree graph:

A graph with cycles is not a tree graph:

A disconnected graph is not a tree graph:

A tree graph with vertices has edges:

A tree graph is a bipartite graph:

A tree graph is not Hamiltonian:

Possible Issues  (1)

TreeGraphQ gives False for non-explicit graphs:

Introduced in 2010
 (8.0)