I found this algorithm that is WAY beyond my comprehension and JS skills. https://rosettacode.org/wiki/Dijkstra%27s_algorithm#JavaScript Somehow I managed to use it a few months ago for a musical application I'm working on.
It works great... but I realized a while ago that this implementation returns only one of the possible shortest paths between two nodes.
For instance in this graph :
the shortest path between k->g can be either through h, i or j
[EDIT : in that case all my weights are equal to 1, but I do use weights in my system with more complex graphs. I just needed a very simple example to explain...]
So far I managed to retrieve this kind of alternatives by randomizing the graph (I don't even understand how it worked...), to get varying destinations when exploring it, but this is far from convenient. It will become heavier when dealing with bigger graphs, and in any case I just realized I need the full list of smallest paths for higher-level calculations I'm making in my system.
Does anyone have an idea of how I could modify this code to get all possibilities? I found similar links on stackoverflow but with different implementations or languages that I really don't know at all.
Any help will be much appreciated ! Thanks
Julien