You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a graph which I would like to copy and change one aspect of it (e.g. weight function). However, it seems like MetaGraph doesn't have a copy constructor:
MetaGraph(graph)
# UndefKeywordError: keyword argument `label_type` not assigned
It would be great if something like that is added. Or alternatively, provide a way to create different views of the same graph with different properties.
deepcopy is a reasonable workaround, but just wanted to leave this warning here, about deepcopy being discouraged in production-level / library code: JuliaLang/julia#58416 (so we should probably leave this issue open)
It's probably good for the graphs ecosystem to commit to ConstructionBase.constructorof always working on graph objects. It will mostly work already as you found with Accessors.jl (that uses it under the hood), but where arguments and type parameters are unusual it may need a method added. ConstructionBase.jl is a small dependency and usually in your deps anyway.
Activity
gdalle commentedon Oct 13, 2025
Can you just use
deepcopy?Krastanov commentedon Oct 13, 2025
deepcopyis a reasonable workaround, but just wanted to leave this warning here, aboutdeepcopybeing discouraged in production-level / library code: JuliaLang/julia#58416 (so we should probably leave this issue open)rongcuid commentedon Oct 13, 2025
Accessors.jlworks so far, though I am not sure if I should rely on knowing the internal representation of theMetaGraphstruct.rafaqz commentedon Oct 14, 2025
It's probably good for the graphs ecosystem to commit to
ConstructionBase.constructorofalways working on graph objects. It will mostly work already as you found with Accessors.jl (that uses it under the hood), but where arguments and type parameters are unusual it may need a method added. ConstructionBase.jl is a small dependency and usually in your deps anyway.