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

Online Help

All Products    Maple    MapleSim


GraphTheory

  

FindCycle

  

find a cycle in the graph

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

FindCycle(G)

FindCycle(G, v)

Parameters

G

-

graph

v

-

vertices of the graph

Description

• 

FindCycle(G) returns a cycle in the graph G, if one exists, and otherwise returns the empty list.

• 

FindCycle(G,v) returns a cycle in the graph G which includes the vertex v, if one such cycle exists, and otherwise returns the empty list.

• 

FindCycle ignores self-loops.

• 

All edges appearing in a cycle must be distinct.

Examples

> 

with⁡GraphTheory:

> 

G≔CycleGraph⁡3,directed

G≔Graph 1: a directed graph with 3 vertices and 3 arcs

(1)
> 

DrawGraph⁡G

> 

FindCycle⁡G

3,1,2,3

(2)
> 

FindCycle⁡G,1

1,2,3,1

(3)

In this example, the empty list is returned since the graph is a tree.

> 

T≔Graph⁡5,1,2,1,3,3,4,3,5

T≔Graph 2: a directed graph with 5 vertices and 4 arcs

(4)
> 

DrawGraph⁡T,style=tree

> 

FindCycle⁡T

(5)

Compatibility

• 

The GraphTheory[FindCycle] command was introduced in Maple 2025.

• 

For more information on Maple 2025 changes, see Updates in Maple 2025.

See Also

IsAcyclic