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

[BUG] topological_sort returns duplicate vertices #213

Closed
stev47 opened this issue Jan 12, 2023 · 3 comments
Closed

[BUG] topological_sort returns duplicate vertices #213

stev47 opened this issue Jan 12, 2023 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@stev47
Copy link

stev47 commented Jan 12, 2023

Description of bug
topological_sort may return duplicate vertices

How to reproduce

g = SimpleDiGraph([Edge(2 => 1)])
topological_sort(g)

Expected behavior

[2, 1]

Actual behavior

[2, 1, 1]

Code demonstrating bug
see above

Version information

julia> versioninfo()
Julia Version 1.8.3
Commit 0434deb161e (2022-11-14 20:14 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × AMD A10-7860K Radeon R7, 12 Compute Cores 4C+8G
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, bdver3)
  Threads: 1 on 4 virtual cores
Environment:
  JULIA_PKG_USE_CLI_GIT = 1

(@v1.8) pkg> status Graphs
Status `~/.julia/environments/v1.8/Project.toml`
  [86223c79] Graphs v1.7.4 `~/.julia/dev/Graphs`

Additional context
none

@stev47 stev47 added the bug Something isn't working label Jan 12, 2023
@simonschoelly
Copy link
Member

Uh, this is bad. topological_sort is defined in the Experimental submodule (where correctness is less guaranteed) and should not be exported outside, but it is, because we import the topological_sort symbol from outside.

In the meantime, one should probably use topologial_sort_by_dfs - that one seems to work correctly, at least for that particular case.

@simonschoelly
Copy link
Member

A possible fix can be found here: #214

@gdalle gdalle added this to the v1.9 milestone Jun 28, 2023
@gdalle gdalle moved this to Todo in Graphs triage Jul 3, 2023
@gdalle
Copy link
Member

gdalle commented Sep 14, 2023

This is fixed

julia> g = SimpleDiGraph([Edge(2 => 1)])
{2, 1} directed simple Int64 graph

julia> topological_sort(g)
2-element Vector{Int64}:
 2
 1

@gdalle gdalle closed this as completed Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Todo
Development

No branches or pull requests

3 participants