I am learning javascript and data structures at the same time and struggling with my output for a graph. Can anyone help me fix my code to output all available paths between start and end node?
If I enter F to C I get the following:
F -> B C :3
F -> A D G :4
F -> A D E :3
F -> C B E F G :7
F -> C D :3
F -> D :1
F -> B D :3
F to C
F D B
F D C
F D
F D E
F
F D G
I'd like the first output to show all available paths from F to C. All its doing now is showing all available paths. The second output is showing all available paths but not correctly.
I'm trying to make the first output show the following when I enter F and C:
F -> D C: 2
F -> D E C: 4
F -> D B A C: 5
F -> D G B A C: 7
I've looked at these:
https://en.wikipedia.org/wiki/Depth-first_search
All the paths between 2 nodes in graph
http://www.quora.com/What-are-good-ways-to-find-all-the-possible-paths-between-two-nodes-in-a-directed-graph
Graph Algorithm To Find All Connections Between Two Arbitrary Vertices
https://mathematica.stackexchange.com/questions/25779/finding-all-simple-paths-between-two-vertices-in-a-graph
https://mathematica.stackexchange.com/questions/4128/finding-all-shortest-paths-between-two-vertices
and many others and I am still stuck.
My code is here: https://jsfiddle.net/jtlindsey/584hh0vf/3/
My two outputs so far start at line number 116 and 209 in the code.