Shortest Path | Dijkstra's Algorithm Explained and Implemented in Java | Graph Theory | Geekific

  Рет қаралды 44,501

Geekific

Geekific

Күн бұрын

Пікірлер: 42
@manOfPlanetEarth
@manOfPlanetEarth Жыл бұрын
Love author's distinct pronunciation👍🏼 He definitely thought about audience. And yes: material got really clear only in code. The gist is not a rocket sience but all mechanics comes in code.
@vachadave1706
@vachadave1706 6 ай бұрын
Thank you, you make it so easy!
@vietnguyenquoc4948
@vietnguyenquoc4948 Жыл бұрын
Awesome explanations, how come youtube algorithm do not suggest this?
@samarthtandale9121
@samarthtandale9121 Жыл бұрын
Amazing Content !!! How did you get your fundamentals so right at java, if there's a book I would like to know about it!
@geekific
@geekific Жыл бұрын
Thanks man, glad I could help! There is no particular book, I research online and try to check as many references as possible and compare them. I try not to stick to one particular reference. Even if I am already knowledgeable in the topic of the video I am currently working on, I still do the research in order not to miss anything out and try to deliver everything that needs to be delivered :)
@samarthtandale9121
@samarthtandale9121 Жыл бұрын
@@geekific That's great and very unique attitude ! Anyways just a friendly suggestion, when you explain a code snippet in terms of algorithm sometimes it's hard to find which part you are taking about .. so you can maybe highlight that portion for the moment I think, it's just my personal opinion ... But nevertheless I'm huge fan of your content and Thanks a lot 🙌🏼
@geekific
@geekific Жыл бұрын
Will keep this in mind for future videos! Thanks for the feedback :)
@mmm-ie5ws
@mmm-ie5ws Жыл бұрын
The code was hard to follow and you didnt give an explanation of how the algorithm is correct. Maybe for an expert who already knows this stuff this video would make sense.
@geekific
@geekific Жыл бұрын
Sorry to read that! I would be happy to answer any question you may have regarding the video in the comments section :) Let me know!
@aldo.express
@aldo.express Жыл бұрын
lol disagree, this java code is very readable, the naming convention is very simple and logical and the use of streams makes it much simpler than using a bunch of for-loops. If you're having a lot of trouble with the code part then make sure you pause and go line by line, and even with pen and paper if necessary, until you understand all the individual steps and can put them together.
@Carrymejane
@Carrymejane 10 ай бұрын
U can search another resources
@manOfPlanetEarth
@manOfPlanetEarth Жыл бұрын
Hi, man again:))) Doing this algo with pen and paper I revealed some point for discussion. At some moment, especially for more connected graphs, both settled and unsettled collections begin to contain the same nodes☝🏼 Moreover, unsettled collection starts containing multiple duplicates of that same nodes. Yes, your realization still works right but all above brings some meaning disruption (especially simultaneous presence of some node in both collections opposite in their calling) and as for me I came up with two options to fix that. 1. Use TreeSet structure for unsettled list (then use pollFirst() method) 2. Do check: if(! unsettledNodes.contains(entry.getKey())) unsettledNodes.add(entry.getKey()); Your thoughts?:)
@geekific
@geekific Жыл бұрын
That was a thorough investigation! Yup, I see no harm in either solutions :) Proud of you!
@manOfPlanetEarth
@manOfPlanetEarth Жыл бұрын
@@geekific Small disclaimer:) My only goal here is to grow. I am preparing for interview and every eminent company check ppl to REALLY understand algos and trees and graphs. No shallow touch will satisfy them😁 So I tend not to get off any topic until I get a feeling that I at least have no more questions for myself on this topic. That's why all my comments here are arising:)) Hope others may also find comments useful for them : watchers may see veiled aspects they would have overlooked otherwise, you receive thoughtful feedback and can deploy it at your discretion. We all always have smth to learn at least a little bit deeper😉 Plan to break down rest of graphs and all trees playlist. I feel more questions are coming:)))
@geekific
@geekific Жыл бұрын
No worries man ask all you want, happy I can help! Good luck with your interviews :)
@anjaliverma5834
@anjaliverma5834 2 жыл бұрын
I need the code of it, from the given link of Github - it is difficult to get the correct code. Can u please provide it
@geekific
@geekific 2 жыл бұрын
Hello! The particular code snippet for this algorithm wasn't yet pushed to GitHub, sorry about that :( We are working on keeping the repo as much as possible up to date. Stay Tuned!
@glorysonhorace3265
@glorysonhorace3265 Жыл бұрын
Thank you
@SabbraCadabra11
@SabbraCadabra11 2 жыл бұрын
Hi! First of all, many thanks for the video, it's enormously helpful. I'm using this as a blueprint for my college assignment. However, I've got to write it in C# and I'm not that good in Java so could you please explain, how could I write this while loop in the calculateShortestPath method without using streams (can be still in Java)? Or at least how could I replace the .filter line when I'm not using stream?
@geekific
@geekific 2 жыл бұрын
Hello! Glad it was helpful :) The filter is basically an if-statement inside a for-loop. Or you can download a Java IDE (I use IntelliJ) and it will help you easily convert between streams and loops! (Alt+Enter on the stream keyword or for keyword for options) Cheers :)
@SabbraCadabra11
@SabbraCadabra11 2 жыл бұрын
@@geekific Will do so, a huge thanks once again!
@Talaria.School
@Talaria.School 2 жыл бұрын
Hi thanks for effort It would have been good to add a repo to get the code. Anyway great effort!
@geekific
@geekific 2 жыл бұрын
The link to the repo can be found in the description. Cheers!
@Talaria.School
@Talaria.School 2 жыл бұрын
@@geekific thanks sorry for my lack of look anyway great explanation
@zukisamaliwa7668
@zukisamaliwa7668 2 жыл бұрын
Can you add from where you left off by reading from a CSV file and calculate the shortest path please
@geekific
@geekific 2 жыл бұрын
Hello! I'll be more than happy to enrich my videos with your suggestions :) Can you please detail what is it you are asking for exactly?
@AvgABC561
@AvgABC561 2 жыл бұрын
I can't use the toList() method on my Stream :/, do you know any solution to that?
@geekific
@geekific 2 жыл бұрын
It was introduced in Java 16
@manOfPlanetEarth
@manOfPlanetEarth Жыл бұрын
1:11 "any sub-path B to D of the shortest path..." Not "any", but simply "sub-path B to D...", because there is only ONE sub-path for the shortest path.
@geekific
@geekific Жыл бұрын
In this example, yes, but the sentence itself can be generalized on any graph! :)
@manOfPlanetEarth
@manOfPlanetEarth Жыл бұрын
@@geekific How can it be? You mean not strict minimum? Like a few shortest paths with the same length?
@geekific
@geekific Жыл бұрын
@@manOfPlanetEarth I mean if you found the shortest path from node A in any graph to a node D in that same graph, then if node B is on that path, then the shortest path from B to D coincides with the path you previously found!
@manOfPlanetEarth
@manOfPlanetEarth Жыл бұрын
@@geekificYes:) That's right what I pointed at:) There's only one sub-path of any shortest path:) If B is not on the shortest path then that's another story.
@manOfPlanetEarth
@manOfPlanetEarth Жыл бұрын
5:20 Any reason you use Collections.singleton(source) instead of Set.of(source)?🤔
@geekific
@geekific Жыл бұрын
In this example, no, both work fine :) But you just gave me an idea for a video :P Cheers!
@manOfPlanetEarth
@manOfPlanetEarth Жыл бұрын
@@geekific I LOVE your videos!!!!:)))) Will be looking forward for that video😊 [topic] I bet on the second because of the brevity:) ps. thank you for communicating in comments!
@hankie5
@hankie5 Жыл бұрын
will it works in undirected graph?
@geekific
@geekific Жыл бұрын
An undirected graph is basically a bi-directional directed graph!
@hankie5
@hankie5 Жыл бұрын
@@geekific ooooh, yeah, thank you
@hankie5
@hankie5 Жыл бұрын
@@geekific i thought, that will be an invifinity cycle
@trollface1994
@trollface1994 Жыл бұрын
Werrt ???
@weihyac
@weihyac Жыл бұрын
thank you
Dijkstra's Algorithm - Computerphile
10:43
Computerphile
Рет қаралды 1,3 МЛН
One day.. 🙌
00:33
Celine Dept
Рет қаралды 42 МЛН
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 3 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 9 МЛН
Dijkstra's Shortest Path Algorithm | Graph Theory
24:47
WilliamFiset
Рет қаралды 210 М.
13. Dijkstra
57:22
MIT OpenCourseWare
Рет қаралды 30 М.
Implement Dijkstra's Algorithm
6:36
NeetCodeIO
Рет қаралды 62 М.
3.6 Dijkstra Algorithm - Single Source Shortest Path - Greedy Method
18:35
The hidden beauty of the A* algorithm
19:22
Polylog
Рет қаралды 900 М.
How Dijkstra's Algorithm Works
8:31
Spanning Tree
Рет қаралды 1,4 МЛН
One day.. 🙌
00:33
Celine Dept
Рет қаралды 42 МЛН