Rename algorithms by what they return instead of their creator
Currently, many algorithms are not discoverable unless you know who created them. We should instead export more explicit function names, and add a type-based mechanism for dispatch with a reasonable default choice. For instance,
function dijkstra(g, v)
...
end
function a_star(g, v)
...
end
might become
struct Dijkstra end
struct Astar end
function shortest_path(::Type{Dijkstra}, g, v)
...
end
function shortest_path(::Type{Astar}, g, v)
...
end
shortest_path(g, v) = shortest_path(Dijkstra(), g, v)
👍 for a problem bases approach instead of a solution based one.
In some cases it might also make sense to use some kind of heuristic in such a function to select the optimal algorithm.
Although maybe shortest path with A* is not the best example, as in that case we need more parameters than for dijkstra.
In some cases it might also make sense to use some kind of heuristic in such a function to select the optimal algorithm.
Yeah here I did a dummy example but there are some cases where preliminary checks would make sense. For instance choosing between Dijkstra and Bellman-Ford based on the presence of negative edges