✅ Problems with Dijkstra Algorithm
So this is my take on Dijkstra in C#. After doing everything. My output is completely wrong. Can someone help me with this?
15 Replies
This is my code: https://paste.mod.gg/doqdfjzauhan/0
BlazeBin - doqdfjzauhan
A tool for sharing your source code with the world!
and this is my output
this is what the graph supposed to look like
I think your issue is due to how you're selecting the min vertex, but the way you've written this makes it difficult to follow.
Personally, I'd rewrite this with a more appropriate structure for the graph (as in, create a graph class with definitions of vertices, their neighbors, and edges), that way you don't have to filter out already-processed data and it should make following pseudo-code for the algorithm more straightforward.
@Lilac I once implemented the A* algorithm in unity (C#) with some help of the videoseries of this guy
https://www.youtube.com/watch?v=-L-WgKMFuhE&list=PLFt_AvWsXl0cq5Umv3pMC9SPnKjfp9eGW
It's been ages ago but I believe he also talks about Dijkstra Algorithm maybe it helps you
Sebastian Lague
YouTube
A* Pathfinding (E01: algorithm explanation)
Welcome to the first part in a series teaching pathfinding for video games. In this episode we take a look at the A* algorithm and how it works.
Some great A* learning resources:
http://theory.stanford.edu/~amitp/GameProgramming/
http://www.policyalmanac.org/games/aStarTutorial.htm
Source code: https://github.com/SebLague/Pathfinding
If you'd...
oh thanks for your help
yeah, I took some reference from a cpp program
how can I put all these codes of Dijkstra pathfinder
into a winfoms program
like, have it visualize the route finding process or something? Or what?
I just want it to do the route finding process with the given data
I don't need to input the data or anything
like this
Is this a school assignment or something? Not sure why you'd need this in a winforms app and have no way to interact with it.
yes it's a school assignment
and I have no idea how to code with winforms right now
I have not even started OOP yet
actually it would be better if my team can find routes with input values
but we find it too hard to perform that right now
Create a Windows Forms app with C# - Visual Studio (Windows)
Create a Windows Forms app in Visual Studio with C#, add button controls to the form, and run the code to test your application.
Is part of the assignment doing this in winforms? If so, I would have expected it to be covered during your class at some point.
well we were required to use winfomrs
but we were only briefly introduced with it
in only 1 lesson
Then I'd follow the tutorial and start trying to learn.
okay then I will check out the tutorials