MetaGraphsNext.jl
MetaGraphsNext.jl copied to clipboard
multigraph support
any efforts (issues/branches) to support multigraphs?
https://github.com/QuantumBFS/Multigraphs.jl
Not here, but over on GraphsBase.jl we're trying to hammer out the best interface for that
Ok... so the current strategy is to work this on GraphsBase from scratch instead of using the implementation from Multigraphs.jl ?
The idea of GraphsBase.jl is to discuss whether we can make MetaGraphs(Next).jl obsolete, and also design a better, more flexible interface for the graphs ecosystem. At the moment it is unclear what GraphsBase.jl will support and when, so don't expect too much from it for your current problem.
I haven't looked at the Multigraphs.jl code, but one of the devs told me it's basically a hack changing very little from Graphs.jl, so maybe MetaGraphsNext.jl would... just work? What are you trying to achieve?
I wanna to do a mix, something like:
using Graphs, Multigraphs
using MetaGraphsNext
model_connections = MetaGraph(
Multigraph(); # Graph() # using the usual Graph doesn't account for the second link as expected, Multigraph fails
label_type=Symbol,
vertex_data_type=String,
edge_data_type=Symbol,
graph_data=nothing,
weight_function=identity,
);
model_connections[:src_1] = "one";
model_connections[:src_2] = "two";
model_connections[:model] = "model";
model_connections[:src_1, :model] = :var_1;
model_connections[:src_1, :model] = :var_2;
model_connections[:src_2, :model] = :var_3;
That looks like something which might work, I'll try it out to see where it breaks
no luck?
no time :rofl:
So I took a little look:
- you had an issue in your multigraph constructor
- the
Multigraphtype does not correctly implement theGraphsinterface, because it does not defineis_directed
With a little type piracy, we can make the code not error:
using Graphs, Multigraphs
using MetaGraphsNext
Graphs.is_directed(::Type{<:Multigraph}) = false
model_connections = MetaGraph(
Multigraph(0); # Graph() # using the usual Graph doesn't account for the second link as expected, Multigraph fails
label_type=Symbol,
vertex_data_type=String,
edge_data_type=Symbol,
graph_data=nothing,
weight_function=identity,
);
model_connections[:src_1] = "one";
model_connections[:src_2] = "two";
model_connections[:model] = "model";
model_connections[:src_1, :model] = :var_1;
model_connections[:src_1, :model] = :var_2;
model_connections[:src_2, :model] = :var_3;
But the behavior is as expected: the edge data for (:src_1, :model) is overwritten. I'm not sure how you expected to differentiate between both edges?
julia> model_connections.vertex_labels
Dict{Int64, Symbol} with 3 entries:
2 => :src_2
3 => :model
1 => :src_1
julia> model_connections.edge_data
Dict{Tuple{Symbol, Symbol}, Symbol} with 2 entries:
(:model, :src_1) => :var_2
(:model, :src_2) => :var_3
thanks. I will look again for the use case that I had for this and test if it works. I was mainly a combination of this and plotting the Graph with Makie. Thanks for taking a look.