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

save/load not working? #39

Open
cormullion opened this issue May 29, 2022 · 4 comments
Open

save/load not working? #39

cormullion opened this issue May 29, 2022 · 4 comments

Comments

@cormullion
Copy link

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.

@etiennedeg
Copy link
Member

savegraph saves by default a MetaGraphs using JLD2.jl to HDF5 format.
loadgraph loads by default a MetaGraphs using LG format.
You can load the graph using loadgraph(fn, gname, MGFormat())

We should probably have a consistent behavior here.

@cormullion
Copy link
Author

Thanks, didn't see MGFormat() anywhere...

@etiennedeg
Copy link
Member

Yes, I found it by digging in the code, we should also document this.

@filchristou
Copy link
Contributor

for GraphML support there is this PR JuliaGraphs/GraphIO.jl#49 on hold with an ongoing discussion. Please feel free to share your opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants