JuliaGraphs / JuliaGraphs/MetaGraphs.jl

save/load not working?

Open
#39 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
70
Forks
12
PR merge metrics
No merged PRs in 30d

Description

I thought this should work, but it doesn't:

using Graphs
using MetaGraphs

g = path_graph(5)
mg = MetaGraph(g, 3.0)
set_prop!(mg, :description, "This is a metagraph.")

savegraph("/tmp/test_graph.lg", mg)

mg1 = loadgraph("/tmp/test_graph.lg")
ERROR: LoadError: BoundsError: attempt to access 2-element Vector{SubString{String}} at index [3]
Stacktrace:
  [1] getindex
    @ ./array.jl:861 [inlined]
  [2] indexed_iterate
    @ ./tuple.jl:90 [inlined]
  [3] _parse_header(s::SubString{String})
    @ Graphs ~/.julia/packages/Graphs/zrMoC/src/persistence/lg.jl:62
  [4] loadlg(io::IOStream, gname::String)
    @ Graphs ~/.julia/packages/Graphs/zrMoC/src/persistence/lg.jl:104
  [5] loadgraph
    @ ~/.julia/packages/Graphs/zrMoC/src/persistence/lg.jl:147 [inlined]
  [6] #120
    @ ~/.julia/packages/Graphs/zrMoC/src/persistence/common.jl:15 [inlined]
  [7] open(::Graphs.var"#120#121"{String, LGFormat}, ::String, ::Vararg{String}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Base ./io.jl:330
  [8] open
    @ ./io.jl:328 [inlined]
  [9] loadgraph
    @ ~/.julia/packages/Graphs/zrMoC/src/persistence/common.jl:14 [inlined]
 [10] loadgraph(fn::String)
    @ Graphs ~/.julia/packages/Graphs/zrMoC/src/persistence/common.jl:18
 [11] top-level scope
    @ untitled-55510ba3fa4677b8db7457446bdad39a:10

Is it something to do with the compressed format - savegraph(.. ... metagraph ... , compress=false) doesn't work either?

Using Graphs v1.7.0, MetaGraphs v0.7.1, Julia 1.7.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The stack trace points to src/persistence/lg.jl, especially _parse_header at line 62; start by reproducing the savegraph/loadgraph example with the listed Julia, Graphs, and MetaGraphs versions. Compare the generated .lg file with what loadlg expects, and consider the issue resolved when the example loads successfully without the BoundsError.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.