GraphTheory
IsCaterpillarTree
test if graph is a caterpillar tree
IsLobsterTree
test if graph is a lobster tree
Calling Sequence
Parameters
Description
Definition
Examples
Compatibility
IsCaterpillarTree(G)
IsLobsterTree(G)
G
-
graph
IsCaterpillarTree(G) returns true if G is a caterpillar tree and false otherwise.
IsLobsterTree(G) returns true if G is a lobster tree and false otherwise.
A graph G is a caterpillar tree if it is a tree and there exists a path in G such that every vertex in G is either on the path or adjacent to a vertex on the path.
A graph G is a lobster tree if it is a tree and the result of removing all leaf #nodes of G is a caterpillar tree.
with⁡GraphTheory:
This graph is a caterpillar tree.
G1≔Graph⁡9,1,4,2,4,3,4,4,5,5,6,6,7,7,8,7,9
G1≔Graph 1: an undirected graph with 9 vertices and 8 edges
DrawGraph⁡G1,style=planar
IsCaterpillarTree⁡G1
true
IsLobsterTree⁡G1
This graph is a lobster tree but not a caterpillar tree.
G2≔Graph⁡9,1,2,2,3,3,4,3,6,3,8,4,5,6,7,8,9
G2≔Graph 2: an undirected graph with 9 vertices and 8 edges
DrawGraph⁡G2,style=planar
IsCaterpillarTree⁡G2
false
IsLobsterTree⁡G2
This graph is a tree but not a lobster tree (or a caterpillar tree).
G3≔GraphUnion⁡PathGraph⁡7,PathGraph⁡4,8,9,10
G3≔Graph 3: an undirected graph with 10 vertices and 9 edges
DrawGraph⁡G3,style=spring
IsTree⁡G3
IsLobsterTree⁡G3
The GraphTheory[IsCaterpillarTree] and GraphTheory[IsLobsterTree] commands were introduced in Maple 2025.
For more information on Maple 2025 changes, see Updates in Maple 2025.
See Also
IsTree
Download Help Document