LightGraphs users (and other interested parties): please opine below

I looked at the code a bit and here is one more idea.

struct PathParams{A,names,T}
    algo::A
    params::NamedTuple{names,T}
end

function Base.getproperty(pp::PathParams, s::Symbol)
    return getproperty(getfield(pp, :params), s)
end

struct Dijkstra end

function PathParams(algo::Dijkstra, all_paths=false, track_vertices=false, maxsdist=typemax(Float64))
    PathParams( algo, (all_paths=all_paths, track_vertices=track_vertices, maxsdist=maxsdist))
end

function shortest_paths(g::AbstractGraph, srcs::Vector{U}, distmx::AbstractMatrix{T}, alg::PathParams{Dijkstra}) where {T, U<:Integer}
...
end

This gives you one Dijkstra type and shouldn’t require changing the shortest_paths code past the the methods head because the same exact fields are available using getproperty

4 Likes