-
Notifications
You must be signed in to change notification settings - Fork 19
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
multigraph support #68
Comments
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. 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 🤣 |
So I took a little look:
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 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. |
any efforts (issues/branches) to support multigraphs?
https://github.com/QuantumBFS/Multigraphs.jl
The text was updated successfully, but these errors were encountered: