0

giving a digraph like this:

1 --> 2
1 --> 3
2 --> 4
2 --> 5
3 --> 6
4 --> 7
5 --> 7
5 --> 8
7 --> 9
8 --> 9
6 --> 9

It`s easy to see there are 3 circle-like in graph.

{[1,2,5,8,9], [1,3,6,9]}
{[2,4,7], [2,5,7]}
{[5,7,9], [5,8,9]}

It`s just what I want.Sometimes the digraph has 300 nodes and more, so need a effective algorithm.

xx fox
  • 1
  • What is your current algorithm? – Yoshikage Kira Jun 01 '21 at 03:07
  • Sorry that I have no algorithm now.But I think two ideas: 1. convert digraph to graph and find cycle, then to get 2 different paths. 2. count in_degree(In > 1) and out_degree(Out > 1), then to find paths. now I try the first way to solve this question. – xx fox Jun 01 '21 at 03:17

0 Answers0