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] Extra vertices in Steiner tree #380

Closed
emstoudenmire opened this issue May 28, 2024 · 1 comment
Closed

[BUG] Extra vertices in Steiner tree #380

emstoudenmire opened this issue May 28, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@emstoudenmire
Copy link

Description of bug
Calling the steiner_tree function on a graph sometimes outputs a tree with extra, isolated vertices.

How to reproduce
One example is if the graph is
g =

1 -- 3
  \
   2

then

Actual behavior

steiner_tree(g,[1,3]) with terminal vertices 1 and 3 outputs the graph

1 ->- 3

     2

whereas

Expected behavior
I would have expected the output to be

1 ->- 3 

without vertex 2 being included.

Code demonstrating bug

using Graphs

g = SimpleGraph(3)
add_edge!(g,1,2)
add_edge!(g,1,3)

st = steiner_tree(g,[1,3])

@show nv(st)

println("Steiner tree vertices:")
for v in vertices(st)
  @show v
end
println("Steiner tree edges:")
for e in edges(st)
  @show e
end

which outputs

nv(st) = 3
Steiner tree vertices:
v = 1
v = 2
v = 3
Steiner tree edges:
e = Edge 1 => 3

Version information
Output from versioninfo() surrounded by backticks (``)

Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

Output from ] status Graphs surrounded by backticks (``)
[86223c79] Graphs v1.11.0

@emstoudenmire emstoudenmire added the bug Something isn't working label May 28, 2024
@emstoudenmire
Copy link
Author

Nevermind – my colleague just reviewed this report and pointed out that this is probably the expected and/or necessary behavior, since all vertices in the range 1:nv(g) must be stored by the design of SimpleGraph so then vertex 2 must still be present in the above example.

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
None yet
Development

No branches or pull requests

1 participant