Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

[BUG] Experimental.Traversals.topological_sort not working for non-connected sub-graphs #1565

Open
h-spiess opened this issue May 31, 2021 · 1 comment
Labels
bug confirmed bug producing incorrect results

Comments

@h-spiess
Copy link

h-spiess commented May 31, 2021

Description of bug
The topological_sort in LightGraphs.Experimental.Traversals is not working when non-connected sub-graphs exist in a graph, i.e., graph consists of multiple non-connected graphs.

How to reproduce

using LightGraphs
using LightGraphs.Experimental.Traversals
Adj = [0 0 0 0; 0 0 0 1; 0 1 0 0; 0 0 0 0]
graph = SimpleDiGraph(Adj)
is_cyclic(graph) # false

topological_sort(graph) # incorrect: 3, 2, 4, 2, 4, 1
topological_sort_by_dfs(graph) # correct: 3, 2, 4, 1

Expected behavior
topological_sort_by_dfs is correct. In topological_sort nodes are probably traversed multiple times.

Actual behavior
See above.

Code demonstrating bug
See reproduction.

Version information

Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, sandybridge)

LightGraphs v1.3.5

Additional context
Hey, I'm aware that this happens in code that is experimental but I think the bug is worth reporting.

BTW, i really like your package :) Thanks a lot for your great work :)

@h-spiess h-spiess added the bug confirmed bug producing incorrect results label May 31, 2021
@sbromberger
Copy link
Owner

Thanks for your comments. Since this function is in Experimental, I think the best we can do is to try to find someone willing to troubleshoot it and work on the bug. I don't know who originally wrote the function; the history shows that I committed it but I'm not sure it's mine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed bug producing incorrect results
Projects
None yet
Development

No branches or pull requests

2 participants