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

Convert a Vector{Integer} to Vector{Edge} function #162

Open
filchristou opened this issue Aug 11, 2022 · 1 comment
Open

Convert a Vector{Integer} to Vector{Edge} function #162

filchristou opened this issue Aug 11, 2022 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@filchristou
Copy link
Contributor

Locally I very often use the following function to convert Vectors of Integers to Vector of Edges.

edgeify(p::Vector{T}) where T<:Integer = map(Edge , zip(p, p[2:end]));

As a result it ends up being defined in many local packages.
Do you think it would make sense to have something similar in Graphs.jl ?

Of course it would be nice to probably change the signature to be functional for any E<:AbstractEdge type.

I was also thinking about dispatching the Base.convert function, but maybe we don't want any automatic conversion to take place. What do you think ?

@gdalle gdalle added the enhancement New feature or request label Nov 20, 2022
@gdalle
Copy link
Member

gdalle commented Nov 20, 2022

To clarify for onlookers, this function takes a path represented as a list of vertices and returns the correponding list of edges.
In principle this would make sense, but as you noticed the current implementation only works for the Edge type and not for any edgetype. The trouble is that some edgetypes might require more than source and destination within the constructors (we ran into this in #116)

@gdalle gdalle added this to the v2.0 milestone Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants