Tarjan's algorithm is a linear-time algorithm for finding all strongly-connected components of a directed graph.
Questions tagged [tarjans-algorithm]
54 questions
33
votes
3 answers
Tarjan cycle detection help C#
Here is a working C# implementation of tarjan's cycle detection.
The algorithm is found here:
http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm
public class TarjanCycleDetect
{
private static…

user623879
- 4,066
- 9
- 38
- 53
18
votes
3 answers
Functional implementation of Tarjan's Strongly Connected Components algorithm
I went ahead and implemented the textbook version of Tarjan's SCC algorithm in Scala. However, I dislike the code - it is very imperative/procedural with lots of mutating states and book-keeping indices. Is there a more "functional" version of the…

pathikrit
- 32,469
- 37
- 142
- 221
17
votes
4 answers
How do I learn Tarjan's algorithm?
I have been trying to learn Tarjan's algorithm from Wikipedia for 3 hours now, but I just can't make head or tail of it. :(
http://en.wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm#cite_note-1
Why is it a subtree of the DFS…

Nihal
- 245
- 1
- 3
- 12
15
votes
2 answers
Tarjan's strongly connected components algorithm in python not working
I implemented the Tarjan's strongly connected components algorithm, according to wikipedia, in Python, but it isn't working. The algorithm is quite short and I cannot find any difference, so I cannot tell why it isn't working. I tried to check the…

jmora
- 491
- 3
- 14
14
votes
3 answers
Does Tarjan's SCC algorithm give a topological sort of the SCC?
I've been studying SCC and algorithms about them, and I've seen that people almost always mention that Kosaraju's algorithm finds the SCC and also gives them ordered in a (reversed) topological sort.
My question is: doesn't Tarjan's algorithm also…

Augusto
- 143
- 1
- 6
12
votes
1 answer
Iterative version of a recursive algorithm is slower
I'm trying to implement an iterative version of Tarjan's strongly connected components (SCCs), reproduced here for your convenience (source: http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm).
Input: Graph G = (V,…

boo-urns
- 10,136
- 26
- 71
- 107
10
votes
5 answers
Back edges in a graph
I'm having a hard time understanding Tarjan's algorithm for articulation points. I'm currently following this tutorial here: https://www.hackerearth.com/practice/algorithms/graphs/articulation-points-and-bridges/tutorial/. What I really can't see,…

Vlad Iordache
- 468
- 1
- 5
- 16
9
votes
1 answer
Tarjan's strongly-connected components algorithm - why index in the back edge?
I'm studying Tarjan's algorithm for strongly-connected components and the way it works is clear to me. Anyway there's a line I don't understand:
// Consider successors of v
for each (v, w) in E do
if (w.index is undefined) then
// Successor w…

Dean
- 6,610
- 6
- 40
- 90
9
votes
3 answers
Enumerating cycles in a graph using Tarjan's algorithm
I'm trying to determine the cycles in a directed graph using Tarjan's algorithm, presented in his research paper "Enumeration of the elementary circuits of a directed graph" from Septermber 1972.
I'm using Python to code the algorithm, and an…

janvdl
- 300
- 1
- 10
9
votes
1 answer
What does lowlink mean in Tarjan's SCC algorithm?
I was reading the code in the following link http://www.cosc.canterbury.ac.nz/tad.takaoka/alg/graphalg/sc.txt
I kept bumping into the word "low-link", and I have no idea what it means.
I know this is a rather nooby question, but can someone explain…

turtlesoup
- 3,188
- 10
- 36
- 50
3
votes
0 answers
Tarjan's algorithm in graph theory
I was learning Tarjan's algorithms differently for each to find strongly connected components, to find articulation points and to find bridges in a graph. All uses the concept of finding discovery time and low-link value using dfs and dfs…

Sumukh Bhat
- 91
- 5
3
votes
2 answers
Non-recursive version of Tarjan's algorithm
I have the following (recursive) implementation of Tarjan's algorithm to find strongly connected components in a graph and it works fine:
public class StronglyConnectedComponents
{
public static List
- > Search(Graph graph)
{
…

user2033412
- 1,950
- 2
- 27
- 47
3
votes
1 answer
Implication Graph Assignment
An implication graph is a directed graph where each node is assigned either true or false and any edge u -> v implies that if u is true then v is true.
I know a straightforward O(n^2) algorithm to find an assignment in a general implication graph…

Corei13
- 401
- 2
- 9
3
votes
0 answers
Tarjan's algorithm: do lowest-links have to be similar for two or more nodes to be inside the same SCC
I'm having some trouble with a homework question involving using Tarjan's algorithm on a provided graph to find the particular SCC's for that graph. While (according to my professor) I have found the correct SCC's by using the pseudo-code algorithm…

JawKnee
- 79
- 7
2
votes
0 answers
About tarjan algorithm, why can't we take low[v] instead of disc[v] when considering the backward edge?
I read an article about Tarjan's algorithm,
blog. In this article, the author asks a question:
In case two, can we take low[v] instead of disc[v] ?? . Answer is NO. If you can think why answer is NO, you probably understood the Low and Disc…

Stary
- 33
- 5