Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible error in stronglyConnectedComponents #279

Open
Quijx opened this issue Apr 14, 2023 · 1 comment
Open

Possible error in stronglyConnectedComponents #279

Quijx opened this issue Apr 14, 2023 · 1 comment

Comments

@Quijx
Copy link

Quijx commented Apr 14, 2023

I was comparing the stronglyConnectedComponents implementation to the pseudocode from Wikipedia (https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm) and I noticed, that in the following line they do not agree:

lowLinks[vertex] = math.min(lowLinks[vertex]!, lowLinks[successor]!);

Wikipedia states in the pseudocode:

// Note: The next line may look odd - but is correct.
// It says w.index not w.lowlink; that is deliberate and from the original paper
v.lowlink := min(v.lowlink, w.index)

and explains:

Note that v.lowlink := min(v.lowlink, w.index) is the correct way to update v.lowlink if w is on stack. Because w is on the stack already, (v, w) is a back-edge in the DFS tree and therefore w is not in the subtree of v. Because v.lowlink takes into account nodes reachable only through the nodes in the subtree of v we must stop at w and use w.index instead of w.lowlink.

I do not understand what all this means jet, so I was not able to create an example where the function yields the wrong result, but I wanted to let you know anyways.

@lrhn
Copy link
Member

lrhn commented Jun 13, 2023

Thanks for the heads up. I personally have no idea what it means either.

@nex3 … was it you who wrote that code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants