0

I am trying to understand an algorithm to count the number of isolated cycles in a graph. By isolated, I mean the cycles that do not share any vertex. Here is an example:

Example Graph

Here, 1-2-4-1 and 3-6-5-3 are the two cycles that do not share any vertex. Hence, the algorithm must return 2. Off course, we can find all possible cycles and then figure out the isolated ones but I was wondering if there could be an alternate method for this special case.

c0der
  • 18,467
  • 6
  • 33
  • 65
  • Assume an edge between 1-3. Which cycles would you consider valid ? – c0der Jan 06 '22 at 06:34
  • Still the same. In that case 3 wont be part of the cycle 1-2-4-1 and still remains isolated from 3-6-5-3 cycle. But 1-2-4-1 and 1-4-3-1 wont be considered isolated as they share at least one vertex. Same goes for 1-4-3-1 and 3-6-5-3. – Rudy Chakraborty Jan 06 '22 at 13:22
  • So is 1-4-3-1 an isolated cycle, making 1-2-4-1 and 3-6-5-3 and 1-2-4-3-1 non-isolated ? – c0der Jan 06 '22 at 14:22
  • Cycles are considered isolated if they do not share ANY vertex. Among the cycles 1-2-4-1, 1-4-3-1, 1-2-4-3-1,3-6-5-3, only 1-2-4-1 and 3-6-5-3 do not share vertex. – Rudy Chakraborty Jan 07 '22 at 15:32
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 12 '22 at 20:24

0 Answers0