JuliaGraphs / Graphs.jl

An optimized graphs package for the Julia programming language
http://juliagraphs.org/Graphs.jl/
Other
451 stars 87 forks source link

[BUG] edges(::SimpleGraph) is broken in 1.10.0 #361

Closed csimal closed 3 months ago

csimal commented 3 months ago

Calling edges on a SimpleGraph in the latest release results in a method error (see below)

How to reproduce See code snippet below.

Expected behavior I expect edges to return an iterator over the edges of the graph.

Actual behavior Calling the function throws an error. If I had to guess, I'd bet on incomplete code refactoring.

Code demonstrating bug

julia> using Graphs

julia> g = SimpleGraph(2)
{2, 0} undirected simple Int64 graph

julia> edges(g)
ERROR: MethodError: objects of type Vector{Tuple{Int64, Int64}} are not callable
Use square brackets [] for indexing an Array.
Stacktrace:
 [1] top-level scope
   @ REPL[44]:1

Version information

 Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Status '~/.julia/environments/graph/Project.toml'
  [86223c79] Graphs v1.10.0
gdalle commented 3 months ago

That's very weird. I cannot reproduce it on my laptop, and something so bad would have been caught by the test suite.

My best guess is that you had defined a variable called edges::Vector{Tuple{Int64, Int64}} earlier in your session, and that it tries to call it instead of the function Graphs.edges.

```julia (@v1.10) pkg> activate --temp Activating new project at `/var/folders/cx/7tl61h5d5tvbhk6xjtnyb85m0000gn/T/jl_xp9PZF` (jl_xp9PZF) pkg> add Graphs Updating registry at `~/.julia/registries/General.toml` Resolving package versions... Updating `/private/var/folders/cx/7tl61h5d5tvbhk6xjtnyb85m0000gn/T/jl_xp9PZF/Project.toml` [86223c79] + Graphs v1.10.0 Updating `/private/var/folders/cx/7tl61h5d5tvbhk6xjtnyb85m0000gn/T/jl_xp9PZF/Manifest.toml` [ec485272] + ArnoldiMethod v0.4.0 [34da2185] + Compat v4.14.0 [864edb3b] + DataStructures v0.18.18 [86223c79] + Graphs v1.10.0 [d25df0c9] + Inflate v0.1.4 [1914dd2f] + MacroTools v0.5.13 [bac558e1] + OrderedCollections v1.6.3 [aea7be01] + PrecompileTools v1.2.1 [21216c6a] + Preferences v1.4.3 [699a6c99] + SimpleTraits v0.9.4 [90137ffa] + StaticArrays v1.9.3 [1e83bf80] + StaticArraysCore v1.4.2 [56f22d72] + Artifacts [2a0f44e3] + Base64 [ade2ca70] + Dates [8ba89e20] + Distributed [b77e0a4c] + InteractiveUtils [8f399da3] + Libdl [37e2e46d] + LinearAlgebra [d6f4376e] + Markdown [a63ad114] + Mmap [de0858da] + Printf [9a3f8284] + Random [ea8e919c] + SHA v0.7.0 [9e88b42a] + Serialization [1a1011a3] + SharedArrays [6462fe0b] + Sockets [2f01184e] + SparseArrays v1.10.0 [10745b16] + Statistics v1.10.0 [fa267f1f] + TOML v1.0.3 [cf7118a7] + UUIDs [4ec0a83e] + Unicode [e66e0078] + CompilerSupportLibraries_jll v1.1.0+0 [4536629a] + OpenBLAS_jll v0.3.23+4 [bea87d4a] + SuiteSparse_jll v7.2.1+1 [8e850b90] + libblastrampoline_jll v5.8.0+1 julia> using Graphs julia> g = SimpleGraph(2) {2, 0} undirected simple Int64 graph julia> edges(g) SimpleEdgeIter 0 julia> versioninfo() Julia Version 1.10.2 Commit bd47eca2c8a (2024-03-01 10:14 UTC) Build Info: Official https://julialang.org/ release Platform Info: OS: macOS (x86_64-apple-darwin22.4.0) CPU: 4 × Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-15.0.7 (ORCJIT, skylake) Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores) ```
csimal commented 3 months ago

I think you're probably right :sweat_smile: . I tried in a new Julia session and couldn't reproduce. I'll blame the lack of sleep for that one.