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

StaticGraphs with edge properties #34

Open
stecrotti opened this issue Dec 17, 2021 · 0 comments
Open

StaticGraphs with edge properties #34

stecrotti opened this issue Dec 17, 2021 · 0 comments

Comments

@stecrotti
Copy link

Hi,
for the kind of stuff we do in my research group (inference on graphs, message-passing algorithms) it would be great to have a graph library where one can store edge properties efficiently. For example we need to save for each edge a message in the form of a Vector{Float64}, then loop over messages incoming to a certain node.

The currently available options seem to be:

  • MetaGraphs.jl: properties are stored using Dicts, which is not very efficient nor elegant
  • SimpleWeightedGraphs.jl: for each edge one can store a 'weight', which is constrained to be <:Real, while it would be useful to have it more generic. Moreover, weights are stored as elements of a SparseMatrixCSC meaning that setting a weight to zero will cause the edge to disappear (!)

One solution would be to assign an index 1,2,...,Nedges to each edge. This way one can keep edge properties (of any type) in a separate vector, indexed by the edge index.
This requires a new type of edge which stores an index in addition to the usual source and destination fields. Something on the lines of

struct SimpleEdgeIndexed{T<:Integer} <: AbstractSimpleEdge{T}
    src::T
    dst::T
    idx::T
end

instead of the StaticEdge you mutuate from SimpleGraphs. Everything else should more or less stay the same.

Do you think this makes sense? If so i can try and write it properly and do a PR.

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

1 participant