JuliaGraphs / MetaGraphsNext.jl

A package for graphs with vertex labels and metadata in Julia
http://juliagraphs.org/MetaGraphsNext.jl/
Other
73 stars 17 forks source link

SimpleGraph() SimpleDiGraph() should return a new instance #42

Closed filchristou closed 1 year ago

filchristou commented 1 year ago

according to conversation on #40 https://github.com/JuliaGraphs/MetaGraphsNext.jl/pull/40#issuecomment-1421208966 users would commonly expect SimpleGraph(mg::MetaGraph) and SimpleDiGraph(mg::MetaGraph) to return a new instance (deep copy) which they can freely modify without repercussions on mg.

gdalle commented 1 year ago

And we should probably add a get_graph function returning the underlying graph object (which may not be a Simple(Di)Graph anymore thanks to #40)

gdalle commented 1 year ago

As of right now these methods do not exist anymore

gdalle commented 1 year ago

Building a Simple(Di)Graph constructor for general graphs should be part of Graphs.jl, not MetaGraphsNext.jl specifically. Closing here

filchristou commented 1 year ago

well, SimpleGraph(mg::MetaGraph) cannot be implemented in Graphs.jl . So if we want the user to be able to use this constructor it should be defined here.

gdalle commented 1 year ago

It doesn't make much sense to me to have a constructor SimpleGraph(mg::MetaGraph), because in the end it would only use interface functions like vertices and edges. So what I had in mind was a SimpleGraph(g::AbstractGraph) constructor, which does belong in Graphs.jl. What do you think?

filchristou commented 1 year ago

I can live with that yes. Users will then have to do something like SimpleGraph(mg.graph). Do you think the users should access fields with dot-notation or should a getgraph function be defined ?

gdalle commented 1 year ago

I can live with that yes. Users will then have to do something like SimpleGraph(mg.graph). Do you think the users should access fields with dot-notation or should a getgraph function be defined ?

Actually no, that's the whole point: since a MetaGraph is a wrapper around any graph object that extends the usual methods like vertices and edges, if SimpleGraph(::AbstractGraph) is defined in the main package, all users have to do is call SimpleGraph(mg) directly

gdalle commented 1 year ago

This will be taken care of by https://github.com/JuliaGraphs/Graphs.jl/issues/98