Graphs.jl
Graphs.jl copied to clipboard
Convert a Vector{Integer} to Vector{Edge} function
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 ?
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 edgetype
s might require more than source and destination within the constructors (we ran into this in #116)