GraphTheory
FindCycle
find a cycle in the graph
Calling Sequence
Parameters
Description
Examples
Compatibility
FindCycle(G)
FindCycle(G, v)
G
-
graph
v
vertices of the graph
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.
with⁡GraphTheory:
G≔CycleGraph⁡3,directed
G≔Graph 1: a directed graph with 3 vertices and 3 arcs
DrawGraph⁡G
FindCycle⁡G
3,1,2,3
FindCycle⁡G,1
1,2,3,1
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
DrawGraph⁡T,style=tree
FindCycle⁡T
The GraphTheory[FindCycle] command was introduced in Maple 2025.
For more information on Maple 2025 changes, see Updates in Maple 2025.
See Also
IsAcyclic
Download Help Document