IsCaterpillarTree - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


GraphTheory

  

IsCaterpillarTree

  

test if graph is a caterpillar tree

  

IsLobsterTree

  

test if graph is a lobster tree

 

Calling Sequence

Parameters

Description

Definition

Examples

Compatibility

Calling Sequence

IsCaterpillarTree(G)

IsLobsterTree(G)

Parameters

G

-

graph

Description

• 

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.

Definition

• 

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.

Examples

> 

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

(1)
> 

DrawGraph⁡G1,style=planar

> 

IsCaterpillarTree⁡G1

true

(2)
> 

IsLobsterTree⁡G1

true

(3)

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

(4)
> 

DrawGraph⁡G2,style=planar

> 

IsCaterpillarTree⁡G2

false

(5)
> 

IsLobsterTree⁡G2

true

(6)

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

(7)
> 

DrawGraph⁡G3,style=spring

> 

IsTree⁡G3

true

(8)
> 

IsLobsterTree⁡G3

false

(9)

Compatibility

• 

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