Algorithm to Group All the Cycles Together
Posted
by Ngu Soon Hui
on Stack Overflow
See other posts from Stack Overflow
or by Ngu Soon Hui
Published on 2010-04-03T12:15:52Z
Indexed on
2010/04/03
12:23 UTC
Read the original article
Hit count: 186
I have a lot of cycles ( indicated by numeric values, for example, 1-2-3-4
corresponds to a cycle, with 4 edges, edge 1
is {1:2}
, edge 2
is {2:3}
, edge 3
is {3,4}
, edge 4
is {4,1}
, and so on).
A cycle is said to be connected to another cycle if they share one and only one edge.
For example, let's say I have two cycles 1-2-3-4
and 5-6-7-8
, then there are two cycle groups because these two cycles are not connecting to each other. If I have two cycles 1-2-3-4
and 3-4-5-6
, then I have only one cycle group because these two cycles share the same edge.
What is the most efficient way to find all the cycle groups?
© Stack Overflow or respective owner