Find the longest cycle in a graph?
Answers
Answered by
0
I need to find the longest cycle in a directed graph using DFS.
I once saw this Wikipedia article describing the way of doing this, and I think it approached the problem something like marking the node with one of three states: Node not yet visited, Finished searching the node, and Node visited, but not yet finished visiting.
I would be grateful if anyone could share the link with me. By the way, it isn't Tarjan's Algorithm.
The problem below is what I'm trying to solve, in case you'd like to know.
The two digits given in the first line is N and M, each representing the number of nodes and the number of directed edges.
From the second line is given M sets of two digits A and B, which means that node A and B are connected but you can only traverse the node from A to B.
I once saw this Wikipedia article describing the way of doing this, and I think it approached the problem something like marking the node with one of three states: Node not yet visited, Finished searching the node, and Node visited, but not yet finished visiting.
I would be grateful if anyone could share the link with me. By the way, it isn't Tarjan's Algorithm.
The problem below is what I'm trying to solve, in case you'd like to know.
The two digits given in the first line is N and M, each representing the number of nodes and the number of directed edges.
From the second line is given M sets of two digits A and B, which means that node A and B are connected but you can only traverse the node from A to B.
Similar questions