1

Trying to implement Dijkstra's via the instructions in this article:

https://medium.com/@adriennetjohnson/a-walkthrough-of-dijkstras-algorithm-in-javascript-e94b74192026

My repl below:

https://repl.it/@Stylebender/DJIK#index.js

  1. The actual Dijkstra method within the Graph class is throwing a not defined error. Just wondering is there a typo or something I did wrong on my end?

  2. In any case, would this be a solid implementation of Dijkstra's?

LightCC
  • 9,804
  • 5
  • 52
  • 92
KamiWar
  • 41
  • 5

1 Answers1

1

In the end change findPathWithDijkstra("Fullstack", "Cafe Grumpy"); to map.findPathWithDijkstra("Fullstack", "Cafe Grumpy");

You have created findPathWithDijkstra in the Graph class so you need to call it through an object, in your case map

Ghost
  • 735
  • 5
  • 16
  • Oh wow I'm a moron. Thank you! Btw, is this a good implementation of Dijkstra's algorithm? – KamiWar Jun 21 '20 at 14:18
  • There may be, I'm no expert so you should probably wait for someone more experienced to answer that question. The algorithm however, seems fine to me. I don't see any extra steps and that's the one I studied in school so it's the only one I know. – Ghost Jun 21 '20 at 14:38