Tarjan's algorithm: do lowest-links have to be similar for two or more nodes to be inside the same SCC

213 views Asked by At

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 found here, some of the nodes in my SCC's do not share the same lowest-link number as the root node for that SCC.

From what I can gather from the pseudo-code, this is because if an un-referenced node i (which is the input node for the current recursive call to the algorithm) has an arc to an already visited node i + 1 which is not the root node, then the algorithm sets is LL = MIN(i.LowestLink, (i + 1).index), and (i + 1).index may not be equal to its own lowest-link value anymore.

For example (this is similar to a part of the graph from the problem I'm trying to solve): if we have nodes in N = {a, b, c, d}, and arcs in E = {a ⇒ c, c ⇒ b, c ⇒ d, b ⇒ a, d ⇒ b}, and our root node which we start the algorithm from is a, then:

1.1) We set a.index = 1 (using 1 rather than 0), a.LL = 1, and push a onto the stack; a has a single arc to c, so we check c; finding that it is undiscovered, we call the algorithm on c.

2.1) We set c.index = 2, c.LL = 2, and push c onto the stack; c has two arcs, one to b, and one to d. Assume our for loop checks b first; b is undiscovered, and so we call the algorithm on b.

3.1) We set b.index = 3, b.LL = 3, and push b onto the stack; b has one arc to a; checking a we find that it is already on the stack, and so (by the pseudo-code linked above) we set b.LL = MIN(b.LL, a.index) = a.index = 1; b has no further arcs, so we exit our for loop, and check if b.LL = b.index, it does not, so we end this instance of the algorithm.

2.2) Now that the recursive call on b has ended, we set c.LL = MIN(c.LL, b.LL) = b.LL = 1. c still has the arc from c to d remaining; checking d we find it is undefined, so we call the algorithm on d.

4.1) d.index is set to 4, d.LL is set to 4, and we push d onto the stack. d has one arc from d to b, so we check b; we find that b is already in the stack, so we set d.LL = MIN(d.LL, b.index) = b.index = 3. d has no further arcs, so we exit our for loop and check if d.LL = d.index; it does not, so we end this instance of the algorithm.

2.3) With the recursive call on d ended, we again set c.LL = MIN(c.LL, d.LL) = c.LL = 1. c has no further arcs, and so we end our for loop. We check to see if c.LL = c.index; it does not, so we end this instance of the algorithm.

1.2) With the recursive call on c ended, we set a.LL = MIN(a.LL, c.LL) = 1. a has no further arcs, so we end our for loop. We check if a.LL = a.index; they are equal, so we have found a root node for this SCC; we create a new SCC, and pop each item in the stack into this SCC until we find a in the stack (wich also goes into this SCC).

After these steps all the nodes in the graph are discovered, so running the algorithm with the other nodes initially does nothing, we have one SCC = {a, b, c, d}. However, d.LL = 3 which is not equal to the rest of the nodes lowest-links (which are all 1).

Have I done something wrong here? Or is it possible in this situation to have an SCC with differing lowest-links among its nodes?

0

There are 0 answers