How Dijkstra's Algorithm Works

  Рет қаралды 1,335,083

Spanning Tree

Spanning Tree

Күн бұрын

Dijkstra's Algorithm allows us to find the shortest path between two vertices in a graph. Here, we explore the intuition behind the algorithm - what information we need to keep track of, in what order we need to explore vertices, and what the limitations of the algorithm are.
***
Spanning Tree is an educational video series about computer science and mathematics. See more at spanningtree.me
To be notified when a new video is released, sign up for the Spanning Tree mailing list at spanningtree.substack.com/
Spanning Tree is created by Brian Yu. brianyu.me/
Email me at brian@spanningtree.me to suggest a future topic.

Пікірлер: 727
@beketmyrzanov1979
@beketmyrzanov1979 3 жыл бұрын
This video is ridiculously underrated ((
@vn5051
@vn5051 3 жыл бұрын
istg
@travelrealindia1
@travelrealindia1 3 жыл бұрын
Can't agree more
@thishandleistaken.
@thishandleistaken. 2 жыл бұрын
I noticed that people put everything between is and underrated
@myleshayhurst5187
@myleshayhurst5187 Жыл бұрын
Truuee
@nayankumarbarwa4317
@nayankumarbarwa4317 Жыл бұрын
Criminally underrated, Brian Yu also teaches in Cs50 topics like AI and Web dev
@hongweichen3581
@hongweichen3581 3 жыл бұрын
Came from Computerphile's video after not understanding, and this is just so much better! You made advanced concepts so easy to understand for beginners like me, thank you.
@TainuiaKid1973
@TainuiaKid1973 2 жыл бұрын
Here's the implementation in Python kzfaq.info/get/bejne/jNSEn7pmnJi3k2g.html
@Itachi.Uchiha.Offical
@Itachi.Uchiha.Offical Жыл бұрын
Same! Came from Computerphile, felt dumb, watched this, and understood.
@turuus5215
@turuus5215 Жыл бұрын
Same, concepts should be intuitive for humans.
@dineshkumare1750
@dineshkumare1750 Жыл бұрын
@@TainuiaKid1973 I also came here after seeing Computerphile video😂..
@nayankumarbarwa4317
@nayankumarbarwa4317 Жыл бұрын
This video is criminally underrated
@aries3690
@aries3690 2 жыл бұрын
I cant stress how amazing these animations are! You are a livesaver for "self-learners" like us :)
@acedev003
@acedev003 2 жыл бұрын
Absolutely!
@Yell-Heah
@Yell-Heah 2 жыл бұрын
fuck, dude, yeah. I don't learn anything from my college lectures- I need stuff I can pause and rewind, and my monkey brain does great with visual assistance. needing to basically self-teach myself all my CompSci, I don't wanna think about where I'd be without videos like this
@MichaelKingsfordGray
@MichaelKingsfordGray Жыл бұрын
Learn your real name first!
@MikhailFederov
@MikhailFederov Жыл бұрын
Calling yourself a self learner is meaningless. Everyone is a self learner.
@MichaelKingsfordGray
@MichaelKingsfordGray Жыл бұрын
@@MikhailFederov There is a more respectable term for self-taught: Autodidact.
@Mobin92
@Mobin92 Жыл бұрын
THANK YOU for the part at 6:28 ! Nobody else seems to explain how to actually find the path, and not just it's length.
@Yell-Heah
@Yell-Heah 2 жыл бұрын
I've been agonizing over trying to understand this algorithm for a class for hours- and now I'm about halfway through this video, and I'm already feeling enlightened. It's FINALLY clicking. You're a lifesaver, mate!
@skidoodles
@skidoodles 3 жыл бұрын
For each vertex v: Dist[v] = infinite Prev[v] = none Dist source = 0 Set all vertices to unexplored While destination not explored: V = least valued unexplored vortex Set v to explored For each edge (v, w): If dist[v] + len(v, w) < dist[w]: Dist[w] = dist[v] + len[v, w] Prev[w] = v
@adharlak510
@adharlak510 3 жыл бұрын
Thank you to SpanningTree for the insight and thank you for the memo !
@abam9787
@abam9787 Жыл бұрын
What's the significance of Prev[w] when the latest update of Dist[w] is more important?
@AlumniQuad
@AlumniQuad Жыл бұрын
@@abam9787 6:24
@irrelevant_noob
@irrelevant_noob Жыл бұрын
@Skidoodles the last two lines should be indented more, to indicate they are both part of the "if true" branch of the conditional. Also, why not indent for the while loop?
@ayeyebrazof6559
@ayeyebrazof6559 Жыл бұрын
For each vertex v: Dist[v] = infinite Prev[v] = none Dist[source] = 0 Set all vertices to unexplored While destination not explored: v = least valued unexplored vertex Set v to explored For each edge (v, w): If dist[v] + len(v, w) < dist[w]: Dist[w] = dist[v] + len[v, w] Prev[w] = v
@dominiorrr6510
@dominiorrr6510 Жыл бұрын
I love learning based on examples and this is by far the best example of Dijkstra's algorithm I've seen so far. It covers a lot of aspects that might not be obvious at first. I haven't even learned Dijkstra yet, but it feels trivial to implement after knowing how simple graph algorithms like DFS or BFS work.
@supersakib62
@supersakib62 Жыл бұрын
One thing I realized, visualization is more helpful to grasp a context than just reading about it.
@penguinjuice7543
@penguinjuice7543 Жыл бұрын
Absoloute life saver. Got taught this by a teacher who literally doesn't know computer science so videos like this are vital.
@whatsup_internet
@whatsup_internet 6 ай бұрын
So far the best and easiest explainations i have ever seen on YT yet for dijkstra;s Algo. Great work !!! Thank you :)
@prashanthvaidya
@prashanthvaidya 3 жыл бұрын
The animation is just outstanding! A video on "how" you make these videos or just what inspired you to get started on this creative journey would be awesome. Keep up the amazing work. I have subscribed and also pressed the bell icon. :)
@ujjwalgupta4160
@ujjwalgupta4160 3 жыл бұрын
Kudos to the animation and explation.
@pend_deletepatrickguarente4916
@pend_deletepatrickguarente4916 9 ай бұрын
By far the best video on this subject I have ever seen, FANTASTIC job with those animations they are really good!
@alliepiper4772
@alliepiper4772 3 ай бұрын
I've been watching a few of your videos over the last day or so, and they're all just so good. You really have a knack for explaining complicated concepts with a clear, easy-to-grasp visual style. I think I'd describe your channel as "3blue1brown for computer science" :) I hope that comes off as complementary as it's intended. Kudos, and keep up the great work, I'm looking forward to more!
@keitumetsemolefe3515
@keitumetsemolefe3515 Жыл бұрын
This is the best explanation on Dijkstra's algorithm I've ever come across!! 🙌🙌
@soyandoat4106
@soyandoat4106 2 жыл бұрын
Please continue to do more of this video! Thank you so much for your content!!
@artycrafty8691
@artycrafty8691 Жыл бұрын
Not only the video is underrated but the whole youtube channel is underrated. best of luck you spanning tree. This is the future of education. I feels so good when i look up to such unique educational channels.
@adrienw4704
@adrienw4704 Жыл бұрын
very interesting! i love how you voice over your code. you make it super understandable!
@ajaysrinivas2814
@ajaysrinivas2814 Жыл бұрын
What a great explainer video! Please make more of algorithms. Thanks a lot for making this video.
@johnle7705
@johnle7705 3 жыл бұрын
This channel is a germ!! So glad I found you!
@naughtiusmaximus
@naughtiusmaximus Жыл бұрын
To understand Djikstra, you need to understand Roche and Ves's Theorems. And then Geralt's theorems.
@quadroninja2708
@quadroninja2708 Жыл бұрын
I can't find anything about Ves's and Geralt's theorems. Could you please share some links to these?
@quadroninja2708
@quadroninja2708 Жыл бұрын
oh i see, it's a joke :-)
@naughtiusmaximus
@naughtiusmaximus Жыл бұрын
Its a Witcher joke :D
@ozboomer_au
@ozboomer_au Жыл бұрын
A very helpful video. Just looking at code and some rambling explanation in a book made the algorithm as clear as mud in a beer bottle to me... but this video has made it so abundantly clear... and seeing how code is derived from it is more than helpful. Thanks so much for posting.
@a.nataliia
@a.nataliia 9 күн бұрын
After CS50 that's one of my favourite voice on KZfaq ☺ Thank you Brian for your great work!
@demonking2526
@demonking2526 Жыл бұрын
Very great explanation, I just followed along Dikstra's algorithm in pseudo code and implemented pathfinding in Unity using it. This visual tool really helps explain the algorithm at hand! Great work.
@KingstonFortune
@KingstonFortune 2 жыл бұрын
This is so much better than some other ones I already saw....and that was a nice tip at the end, referring to the negative value.
@qazizayad
@qazizayad Жыл бұрын
i have my Alevel Comp Sci paper 12 hours from now. I love you man. Youre a real life saver
@taumah7302
@taumah7302 Жыл бұрын
Incroyable ! Mes profs n'ont pas réussi à ma faire comprendre cet algo en 1h et là je tombe sur cette vidéo ! Merci tu viens de sauver mon année !
@jaylensung7332
@jaylensung7332 9 ай бұрын
It's amazing that I recognized this voice immediately and realized this random video I picked is actually from Brain! Thank you for all the hard work you've done!
@MartinStaykov
@MartinStaykov Жыл бұрын
I don't think I've ever watched anything ever explained in a clearer way than this.
@smikkelbeer7890
@smikkelbeer7890 Жыл бұрын
By far the best explanation on the internet. Thank you
@chrisogonas
@chrisogonas Жыл бұрын
Excellent illustration of the Dijkstra's algorithm. Superb!
@magik0630
@magik0630 3 жыл бұрын
Excellent walkthrough. 4th video down and I finally get it. Thanks
@BrianOSheaPlus
@BrianOSheaPlus Жыл бұрын
Excellent video. Clear and concise description of Dijkstra's algorithm.
@gauravbhalerao7420
@gauravbhalerao7420 Жыл бұрын
From Google Maps to Project Management (CPM) the applications of this algo are literally limitless
@davngo
@davngo 3 жыл бұрын
Awesome explanation, short and to the point.
@egalomon
@egalomon Жыл бұрын
I don't know why YT is recommending this to me 2 years after its upload, but I gladly clicked on the video! This is pretty much the only thing I remember from when I was studying Geoinformatics before I quit lol so it's a nice throwback for me. Very well explained too! 8:30 for something our professor needed like 2 weeks for
@rockstarpesu
@rockstarpesu 10 ай бұрын
Such a great way to explain the complex topic. Thanks a lot. 😊
@DaveAlexKD
@DaveAlexKD Жыл бұрын
I love this explanation is so simple to understand. Thank you!
@davewilson4493
@davewilson4493 Жыл бұрын
No doubt like many other people, I reinvented a variant of this particular wheel (in my case back in the mid 90s while writing "AI" code for NPCs at a games company). A guy on our team who actually liked writing in x86 assembly language had written a brute-force A-B routefinding function that was slow enough to take up meaningful time. After some playing around in C, I ended up zeroing in on the offspring of Dijkstra which fully explores the graph and finds the shortest routes to everywhere, and it was several orders of magnitude faster than the assembly guy's code.
@nawalkhawar7602
@nawalkhawar7602 Ай бұрын
you're videos are extremely helpful. thank you for making these! Also love the robot
@kacperwodiczko
@kacperwodiczko 2 жыл бұрын
Thank you! You've made it so easy to comprehend
@aakashdp
@aakashdp 3 жыл бұрын
thanks! easy to follow. explained in simple terms.
@ghanshyamtripathi221
@ghanshyamtripathi221 5 ай бұрын
not even kidding this is the best explanation/ visualisation one can ever get Thank you sir!!
@Mercury2wo
@Mercury2wo Жыл бұрын
Fantastic video!! Am watching all your videos back to back
@Adarsh_Tiwari
@Adarsh_Tiwari Жыл бұрын
This is almost similar to the CPM (Critical Path Method) that we study in Project Planning and Management. So beautifully explained
@TheMofRider2
@TheMofRider2 Жыл бұрын
Just wanted to mention that. You're absolutely right 🙂
@OneTrueBadShoe
@OneTrueBadShoe Жыл бұрын
I saw this in a class in 1994 or 5. This has always been my favorite algorithm I've ever learned. Nice video
@namankeshari7332
@namankeshari7332 10 ай бұрын
This is the first video I watched on your channel and on dijkstra's algorithm and damnn it was sooo good! Loved it!
@dailyamazingshortvideos
@dailyamazingshortvideos Жыл бұрын
This is the best explanation,one can ask for. . Waiting for more such algo explanations
@SaidElnaffar
@SaidElnaffar Жыл бұрын
I am sharing this link with my students in the Data Structures course -- Keep it up!
@gargolario
@gargolario 2 жыл бұрын
Great, clean and simple! Congrats!
@rodrigo-tj1gf
@rodrigo-tj1gf 6 ай бұрын
You need to post more, those videos are freaking good
@soniahandle
@soniahandle Жыл бұрын
Exactly what we need more of! Amazing explanation
@javel476
@javel476 2 жыл бұрын
Best video about dijkstra algorithm I have ever seen
@anilsuyal
@anilsuyal 20 күн бұрын
What an amazing explanation, that too with a visualisation. Thank you so much. Please keep posting such Visualisations of algorithms.
@ccsmooth55
@ccsmooth55 Жыл бұрын
Very helpful video. Im a Network Engineer and this is how OSPF works (because it uses Djikstras Alg.). Instead of towns, its nodes (routers) on a network.
@manishmakode6332
@manishmakode6332 11 ай бұрын
Really great animation for explaining the concept, loved it
@saipan1970
@saipan1970 11 ай бұрын
The ambience,sound the illustration and putting the main logic behind this algorithm : Clarity and transparency are optimum.Please do make videos like this for every important algo,a request.Refreshing..
@DontAddMe
@DontAddMe Жыл бұрын
beautifuly explained! Dont stop making these videos. You are the savior of cs students
@firebraingames
@firebraingames 3 жыл бұрын
Great way to get a feel of Dijkstra's Algorithm
@ZenoDovahkiin
@ZenoDovahkiin 20 күн бұрын
Ok but can we appreciate the happy music and the cute robot?
@jibachhyadav7241
@jibachhyadav7241 3 жыл бұрын
Thank you. please cover some topic in Dynamic Programming too!
@SpanningTree
@SpanningTree 3 жыл бұрын
See kzfaq.info/get/bejne/pc-WgZCKu9LWoWw.html for an introduction to dynamic programming!
@minhlaburninghihi5627
@minhlaburninghihi5627 3 жыл бұрын
Coolest video on Dijkstra's ever. So easy to understand, thank you so much.
@CrescentDolluwu
@CrescentDolluwu Жыл бұрын
Besides how great of a job this video explains this concept, The absolute best part is the little blue robot blinking and looking around.
@megamaser
@megamaser 7 ай бұрын
The first time I figured out this algorithm, it was by reading code. That worked, but took way longer than watching this video. This video is very nice. It is clear and touched the most important points. You've made an intuitive understanding of Dijkstra's algorithm easily accessible to anyone. The only thing I would add to this video is at least a brief mention that you would put the data in a heap. This could be a nice segue into a separate video about heaps.
@bapynshngain
@bapynshngain Жыл бұрын
This was really very insightful. I wish more teachers would adopt this method of teaching because it is so much easier to understand than the traditional textbook method!
@tirateehoffenberg8824
@tirateehoffenberg8824 10 ай бұрын
Making a high quality KZfaq videos like this takes a lot more time than drawing nodes and edges on a whiteboard.
@ghad6799
@ghad6799 5 ай бұрын
While giving high quality lectures on white board is skill. Honestly, our education system is fine, just the skill issue of conveying an idea. Fucking hell my "international university" profs can't even speak English.
@matteobecatti3157
@matteobecatti3157 2 жыл бұрын
Very clear explanation, thank you!
@gowinidea
@gowinidea Жыл бұрын
You guys have produced super videos..thanks much!❤
@ghostfjdgcsusvsgsj
@ghostfjdgcsusvsgsj Жыл бұрын
best explanation of dijkstra's algo so far
@Agamista379
@Agamista379 Жыл бұрын
This is amazing. Please keep the good work.
@sayantankundu973
@sayantankundu973 2 жыл бұрын
Just gotta a say, thanks a lot.... U have made it so easy to understand... The animation is very helpful... Keep going
@ChazWinter
@ChazWinter 6 ай бұрын
We are covering this in class right now, and my class loves this video.
@___vandanagupta___
@___vandanagupta___ 10 ай бұрын
The amazing quality of your videos is super underrated
@abdullahmustafa3746
@abdullahmustafa3746 3 жыл бұрын
you are just doing a great job right there, Thank you
@s1mplelance964
@s1mplelance964 2 жыл бұрын
Great video with clear explanation! It would fit those entry level guys.
@DC-zb7uf
@DC-zb7uf 2 жыл бұрын
Best video explanation out of them all, thanks !
@shandou5276
@shandou5276 3 жыл бұрын
This is incredibly well made!
@rocket007
@rocket007 Жыл бұрын
Really cool stuff. I am also happy about the snippet code algorithm at the end
@saragul2806
@saragul2806 Жыл бұрын
Amazing job! I have a logistics course in uni and I didn't understand the class. Lucky me found this video. Thank you!!!
@ajaythombare6235
@ajaythombare6235 7 ай бұрын
Bro why this video has very less likes these 8 min have huge chunk of information
@rpgprime
@rpgprime Жыл бұрын
By far THE best graphical explanation of Dijkstra's algorithm and it covers improving it to get the actual path 👍
@elijahdecalmer613
@elijahdecalmer613 Жыл бұрын
Very great visualisation, thank you
@SimonTheDankOne
@SimonTheDankOne Жыл бұрын
I have a shortest path problem that I am currently working on, and even though I am familiar with the Dijkstra algorithm this somehow just made me instantly realise of my mistake in code. Gracias
@josiasbudaydeveloper5864
@josiasbudaydeveloper5864 Жыл бұрын
This video is amazing, thank you very much for this help!
@JamesCheng999
@JamesCheng999 2 ай бұрын
Great video, very intuitive and help me a lot!
@df_iulia_estera
@df_iulia_estera 2 жыл бұрын
Very useful! Thank you very much for doing this video :D
@darkmaigo
@darkmaigo 14 күн бұрын
Thank you I finally understand it and implement it correctly!
@minhucbui9566
@minhucbui9566 Жыл бұрын
Brilliant explanation. Thank you!
@SatyarthShankar
@SatyarthShankar 2 жыл бұрын
Your channel should grow! Amazing work!
@bscorvin
@bscorvin Жыл бұрын
My professors love bringing up the traveling salesman problem and then not elaborating, so this was fun. Thanks!
@emmanuelonah4596
@emmanuelonah4596 Жыл бұрын
Thank you for this simplification
@gutzimmumdo4910
@gutzimmumdo4910 Жыл бұрын
perfectly explained, intuitive well ordered and perfect example. great work
@HabunoGD1821
@HabunoGD1821 7 ай бұрын
I loved the video and your explanation. I read something out there and I want to share it 3:47 - 4:42 "It's important to note that this approach may have limitations and doesn't always ensure the most accurate result. In certain situations, it could lead to inaccurate estimates if the initial estimation doesn't precisely reflect the reality of the path. In the original Dijkstra's algorithm, continually updating estimations is crucial to ensure the accuracy of the shortest path."
@tongluo9860
@tongluo9860 2 жыл бұрын
I am taking CS50 Edx class, I recognized this voice. It must be you Brain. Wonderful job explaining this concept, just like you did in CS50!
@nielsdaemen
@nielsdaemen 4 ай бұрын
Best explanation of Dijkstra's Algorithm!
@jessojohn9226
@jessojohn9226 11 ай бұрын
i never subscribed a channel just watching one video before..You are so good
@micokun8433
@micokun8433 2 жыл бұрын
very clear and informative
@ssamship2275
@ssamship2275 8 ай бұрын
This video had actually insane timing. Just went over this in class.
@tyronefrielinghaus3467
@tyronefrielinghaus3467 Жыл бұрын
Also...a great voice too. Very clear.
@mdkhaledhossain996
@mdkhaledhossain996 Жыл бұрын
this is just mindblowing, keep creating content like this, you will reach to million subscriber within no time
@amrutaj28
@amrutaj28 Жыл бұрын
Beautiful explanation. Thank u so much.
Understanding B-Trees: The Data Structure Behind Modern Databases
12:39
The hidden beauty of the A* algorithm
19:22
polylog
Рет қаралды 829 М.
Шокирующая Речь Выпускника 😳📽️@CarrolltonTexas
00:43
Глеб Рандалайнен
Рет қаралды 11 МЛН
The delivery rescued them
00:52
Mamasoboliha
Рет қаралды 10 МЛН
$10,000 Every Day You Survive In The Wilderness
26:44
MrBeast
Рет қаралды 127 МЛН
What Is the Pigeonhole Principle?
8:23
Spanning Tree
Рет қаралды 3,3 МЛН
The Art of Linear Programming
18:56
Tom S
Рет қаралды 623 М.
Naming Things in Code
7:25
CodeAesthetic
Рет қаралды 2 МЛН
10 weird algorithms
9:06
Fireship
Рет қаралды 1,1 МЛН
P vs. NP: The Biggest Puzzle in Computer Science
19:44
Quanta Magazine
Рет қаралды 704 М.
How do computers add numbers so quickly?
9:15
Spanning Tree
Рет қаралды 80 М.
Minimax: How Computers Play Games
14:37
Spanning Tree
Рет қаралды 194 М.
AES: How to Design Secure Encryption
15:37
Spanning Tree
Рет қаралды 142 М.
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,5 МЛН
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Шокирующая Речь Выпускника 😳📽️@CarrolltonTexas
00:43
Глеб Рандалайнен
Рет қаралды 11 МЛН