Dijkstra's Algorithm - Computerphile

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ม.ค. 2017
  • Dijkstra's Algorithm finds the shortest path between two points. Dr Mike Pound explains how it works.
    How Sat Nav Works: • Satellite Navigation -...
    Slow Loris Attack: • Slow Loris Attack - Co...
    / computerphile
    / computer_phile
    This video was filmed and edited by Sean Riley.
    Computer Science at the University of Nottingham: bit.ly/nottscomputer
    Computerphile is a sister project to Brady Haran's Numberphile. More at www.bradyharan.com

ความคิดเห็น • 675

  • @TheRoboticLlama
    @TheRoboticLlama 7 ปีที่แล้ว +5534

    To understand recursion, one must first understand recursion.

    • @wesofx8148
      @wesofx8148 7 ปีที่แล้ว +280

      Stack overflow.

    • @wesofx8148
      @wesofx8148 7 ปีที่แล้ว +193

      Navaron No, his joke gave me a stack overflow.

    • @vivekpal1004
      @vivekpal1004 7 ปีที่แล้ว +65

      WesOfX You need a base case.

    • @DigGil3
      @DigGil3 7 ปีที่แล้ว +11

      Should have added some recursion limiting flag...

    • @Oshyrath
      @Oshyrath 7 ปีที่แล้ว +67

      That's deep

  • @MrNacknime
    @MrNacknime 7 ปีที่แล้ว +2423

    I think this type of video is exactly the level of complexity your channel should be at. Stuff around the first undergraduate year of a typical Computer Science student, well explained is understandable for the average viewer but also interesting enough for advanced viewers.

    • @billy653
      @billy653 7 ปีที่แล้ว +90

      We did dijkstra's algorithm in our second year of uni, but it still is appropriate for year 1.

    • @adrianlowenberg
      @adrianlowenberg 7 ปีที่แล้ว +27

      billy653 I did it in high school, as well as A*

    • @lucas34540
      @lucas34540 7 ปีที่แล้ว +94

      Welcome to the Mike Pound fan club. Far and away the best presenter on this channel. There needs to be a Mike Pound playlist if there isn't one already.

    • @anishsarkar120
      @anishsarkar120 7 ปีที่แล้ว +4

      ya most advanced user would have already done this as a part of their course , but still this was an interesting topi to cover and just so many peaple payed attention to the steps as they pointed out the possible mistakes

    • @anishsarkar120
      @anishsarkar120 7 ปีที่แล้ว +7

      this is taught almost anyone in engineering or in a technical field or last year of high school , i was first taught this technique in maths

  • @Pheatrix
    @Pheatrix 7 ปีที่แล้ว +1998

    You finished to early. There were still other nodes in the priority list that had a lower priority than 'E'.
    So it was still possible to find a shorter way!
    Djikstra's Algorithm terminates after the goal node has been processed, not when the first path has been found!

    • @michaelpound9891
      @michaelpound9891 7 ปีที่แล้ว +645

      Yep! Thanks for pointing this out, I spotted it too late :) I should have expanded d and f. Had there been a path from say d to e that could have changed things.

    • @espinosaleal
      @espinosaleal 7 ปีที่แล้ว +7

      Hey Mike, what is the name of the C++ book behind you? Do I see the Elements of Statistical Learning as well there?

    • @Super_Cool_Guy
      @Super_Cool_Guy 7 ปีที่แล้ว +3

      Melvin Klein C++ he needs vitamin C more like. ...

    • @oahda
      @oahda 7 ปีที่แล้ว +6

      If you're ever interested in getting back into it and want some less outdated material since C++ has been changing a lot in the last five years or so, I highly recommend Scott Meyer's 'Effective modern C++' (which presupposes a knowledge of older C++, however, but since you seemed to have that)! c:

    • @daggawagga
      @daggawagga 7 ปีที่แล้ว +1

      If you're into videos, CppCon has uploaded a great number of them over the last few years about almost any C++ topic you could imagine too. They're really nice especially for the modern examples.

  • @KnakuanaRka
    @KnakuanaRka 4 ปีที่แล้ว +46

    A
    One big mistake that I think a lot of people have already noticed: you do not stop the algorithm the instant you find a path to the end. Instead, you just put the end node in the list and continue until you fully process the end note and put it in the discard. This is because the first path you find may not be the optimal one, especially when, as shown in the video, multiple partial paths exist with the same length so they could be processed in any order, so you need to keep working until you can be sure you’ve gotten all possible paths.
    For example, take a simple square with four nodes like this, with paths along the four edges with lengths as such:
    S-1-A
    | |
    2 4
    | |
    B-2-E
    In order to find the shortest path S to E, Dijkstra’s algorithm would start with this:
    S0 Ai Bi Ei
    First step is to process S; it has paths of 1to A and 2 to B, creating this:
    (S0) A1S B2S Ei
    Next is to process A, which has only one open path, of 4 to E for 4+1=5:
    (S0 A1S) B2S E5A
    Now as you described it, the algorithm would end immediately, with the path of SAE of length 5. But in fact, this path is obviously not optimal. In the correct algorithm, one would process B next, which has a path of length 2 to E for a lesser total of 4:
    (S0 A1S B2S) E4B
    Now you would process E, which had nothing to do, and now the algorithm would end and return the true shortest path of SBE length 4.
    Heck, your own video shows an example of why you need to do this. At the very start, you have a triangle with sides 7-3-2, and you note that the SA path of length 7 is left there until you process B, which gives you a shorter SBA math that overrides the other one. If E was at the other end of that 7 path instead of A, it would have returned immediately and ignored the shortcut!

  • @minemaarten772
    @minemaarten772 7 ปีที่แล้ว +327

    Real Dijkstra's Algorithm implementations actually continue searching until the destination node E is at the top of the priority queue, as theoretically either from D or F there could be a path of weight < 1 to node E, leading to a shorter path than the found one of weight 7, in the situation at 8:31

    • @TakanashiYuuji
      @TakanashiYuuji 7 ปีที่แล้ว +3

      Yea, it's possible that there is, for instance, a faster path from G to E that passes through another node.

    • @zamadatix
      @zamadatix 7 ปีที่แล้ว +12

      A large number (most?) of practical implementations use integer weights disallowing 0 (which is equivalent to 2 nodes being the same node anyways). This allows a linear runtime complexity.

    • @TakanashiYuuji
      @TakanashiYuuji 7 ปีที่แล้ว +3

      Daniel Smith that seems like a rare edge case to me. If G-E was 3 instead there could still be a shorter path.

    • @zamadatix
      @zamadatix 7 ปีที่แล้ว +5

      Rare edge case for what in particular? Wanting a linear time guarantee with a simple solver? No, most paths are just ints because it's easier to deal with computatinoally and algorithmically.
      As for if G-E was 3 yes, there could still have been a shorter path. Same as if you had a different graph. Thing is he already checked the length from G->E and was likely under the assumption all weights are integers (partially because they all are, partially because he references "the implementation he knows" in networking at the beginning which is likely integer limited for the reason I mentioned.

    • @isaacdouglas1119
      @isaacdouglas1119 4 ปีที่แล้ว +5

      Yeah kind of annoying that they didn't show that and just stopped

  • @donniemorrow
    @donniemorrow 7 ปีที่แล้ว +7

    Dr Mike Pound is consistently making the content I've been enjoying the most on this channel. I'd love to see more videos with him

  • @philipkertsman1498
    @philipkertsman1498 5 ปีที่แล้ว +28

    This is awesome. I really like that you can feel the friendliness and good vibes between Dr. Pound and whoever is shooting the video. The energy passes through. This may seem immaterial, but this helped me engage and absorb more.

  • @mridulagarwal5881
    @mridulagarwal5881 4 ปีที่แล้ว +3

    Before watching this video, I've always found myself confused regarding Dijkstra's implementation. This might just be the simplest and the best video for understanding how Dijkstra's algorithm works. Thank you very much!

  • @danieldaniels1172
    @danieldaniels1172 7 ปีที่แล้ว

    I haven't enjoyed a presenter on computerphile this much since Tom Scott. A Dr. Mike Pound playlist should be a priority. He is excellent at explaining every topic I have watched so far. Thank you very much for the content guys.

  • @ghufranullah
    @ghufranullah 7 ปีที่แล้ว +206

    Please do A-star next!

    • @siddharth_desai
      @siddharth_desai 7 ปีที่แล้ว +32

      I'm pretty sure the end bit about the heuristics was leading into that, haha

    • @EddieHart
      @EddieHart 7 ปีที่แล้ว +4

      smash mouth? 😂

    • @dbueno6375
      @dbueno6375 7 ปีที่แล้ว +10

      It's exactly dikstras but you have a heuristic that estimates the distance to the goal at each node. You add this heuristic to path length and that now becomes the priority. It's very very similar.

    • @doubleru
      @doubleru 7 ปีที่แล้ว +3

      And then they'll get to the really pervy stuff, like customizable contraction hierarchies...

  • @dino130395
    @dino130395 7 ปีที่แล้ว +51

    In always enjoy watching Mike explain things! Nice video!

  • @quarkyquasar893
    @quarkyquasar893 7 ปีที่แล้ว +186

    No, not my knee!
    -Dijkstra

    • @yunusbahari
      @yunusbahari 7 ปีที่แล้ว +37

      Too much witcher detected

    • @wesofx8148
      @wesofx8148 7 ปีที่แล้ว +1

      Pathfinding error.

    • @dogemaester
      @dogemaester 6 ปีที่แล้ว +1

      Dee-kstra or Dy-kstra?

    • @Neoplasie1900
      @Neoplasie1900 4 ปีที่แล้ว

      @@dogemaester If you want to be closer to the original pronunciation, it would be Dee-kstra. Dy-kstra sounds more "englishified".

  • @a.b.c.d.e...
    @a.b.c.d.e... 3 ปีที่แล้ว

    I have read and watched other stuff on this topic before, but I never felt like actually getting it. You know, when you understand something, but you still feel uncertain about whether you actually got it. Now I watched this and my mind is clear. I get it, it feels intuitive now. Thank you so so much!

  • @schogaia
    @schogaia 7 ปีที่แล้ว +157

    Dr Mike Pound just rocks!

  • @roleben3009
    @roleben3009 ปีที่แล้ว

    This video was actually great, I perfectly understood how the algorithm works in a simple but nevertheless complex concept. One of the best explanations so far. Great video!

  • @matthijndijkstra25
    @matthijndijkstra25 7 ปีที่แล้ว +636

    Ah, Dijkstra. What a lovely name.

    • @Saltofreak123
      @Saltofreak123 7 ปีที่แล้ว +74

      it just rolls of the tongue

    • @IDixuu
      @IDixuu 7 ปีที่แล้ว +29

      It does if you're Dutch. You can imagine "ij" being similar to "y"

    • @matthijndijkstra25
      @matthijndijkstra25 7 ปีที่แล้ว +96

      I know, I'm Dutch and my last name is Dijkstra. 😄

    • @MAlgMAlg1
      @MAlgMAlg1 7 ปีที่แล้ว +1

      That does not make it better in English...........

    • @hiddeluchtenbelt6440
      @hiddeluchtenbelt6440 7 ปีที่แล้ว +15

      Matthijn Dijkstra I imagined Dutch people chuckling in the background of this video.

  • @konradd8545
    @konradd8545 2 ปีที่แล้ว

    I just wanted to express my gratitude for the amazing work Computerphile is doing! I'm just going through Dijkstra's algorithm in my Discrete Mathematics course in uni and my lecture is utterly rubbish. Thanks to Computerphile video, I grasped the idea very quickly!

  • @stephenstringfellow1170
    @stephenstringfellow1170 7 ปีที่แล้ว +1

    I really wish this guy was a professor at my university when i was studying. very well explained and feels engaging.

  • @thejimd
    @thejimd 7 ปีที่แล้ว +79

    Dr. Mike is my fav

  • @stanleybacklund5614
    @stanleybacklund5614 5 ปีที่แล้ว +30

    I love how a guest has never looked into the camera on this channel

    • @hastley64
      @hastley64 2 ปีที่แล้ว

      they're all introverts.

  • @atulkoshta641
    @atulkoshta641 3 ปีที่แล้ว

    This guy is always wonderful to hear. Thanks, Dr. Mike :)

  • @kummer45
    @kummer45 ปีที่แล้ว

    This is a great start for videos of such high calliber.
    If something is deeply difficult should be precented like it is with all the difficulties that such topic has. This is what I call authenticity. If it is measure theory then everything should be explained in great detail WITHOUT ommiting difficulty.
    This guy gets it right.

  • @nemoalvaradoTV
    @nemoalvaradoTV 7 ปีที่แล้ว

    Just want to say thanks for the sweet explanation on this algorithm. Couldn't learn it at school lectures but you made it clear.

  • @atulkoshta641
    @atulkoshta641 6 ปีที่แล้ว

    What a lovely explanation Dr. Mike!

  • @PrimumGenus
    @PrimumGenus 4 ปีที่แล้ว

    I asked for the English translation of another Dijkstra's Algorithm lecture video, and this is what I found. The explanation is a whole lot better.

  • @Pumbear
    @Pumbear 7 ปีที่แล้ว +42

    Good job on the graphics. Made the video a lot clearer :)

  • @elysweetmemory
    @elysweetmemory 3 ปีที่แล้ว

    Thanks for the wonderful explanation and the short bit about its downfalls!

  • @gdfauxtrot
    @gdfauxtrot 7 ปีที่แล้ว +7

    My computer organization class will be discussing Dijkstra and priority queues soon, I feel like I just got an amazing head-start.

    • @hellterminator
      @hellterminator 7 ปีที่แล้ว +4

      In that case you better know there's a mistake in the video. Dijkstra's algorithm doesn't terminate until the destination node is at the top of the queue. The way Mike did it here, he found *a* path but *not* necessarily the *shortest* path. If for example the edge between g and e had weight of 14 or more, the shortest path would lead through k, but he wouldn't have found it. In this case Mike did get the shortest path, but he couldn't know that for sure before processing d and f.

    • @TruthNerds
      @TruthNerds 5 ปีที่แล้ว

      Ironically, Dijkstra's algorithm as originally published in 1959 did not use a priority queue, and was asymptotically less efficient (quadratic run time). It took 25 years until Fredman & Tarjan published an upgraded version of it, with priority queue and an average O(n log n) run time.

  • @highlewelt9471
    @highlewelt9471 7 ปีที่แล้ว

    Just yesterday I wondered about the travelling salesman problem and path finding and now you upload this video

  • @MisterAndersonxX
    @MisterAndersonxX 7 ปีที่แล้ว

    Great upload, keep em' coming!

  • @TheThunderSpirit
    @TheThunderSpirit 7 ปีที่แล้ว +2

    great. would love to see more videos on different type of algorithms.

  • @Ericnorify
    @Ericnorify 7 ปีที่แล้ว +1

    That ending seems to be tease for an upcoming A* video! Looking forward to it.

  • @dougie8747
    @dougie8747 7 ปีที่แล้ว +6

    Game developer here, I'd consider Dijkstra's (perhaps more A* but Dijkstra's is perfectly sufficient for small graphs) to be one of the core algorithms that everyone should know. Please do a video on Prim's (or one of the other MST algorithms) as well, my favourite algorithm, after Quicksort of course. :D

  • @ahmedyassien4695
    @ahmedyassien4695 5 ปีที่แล้ว

    OMG i love this guy,i love this channel i missed my lecture where the Dr explained it and by all means i don't think he could've explained it better thanks

  • @mehrosenasir3966
    @mehrosenasir3966 4 ปีที่แล้ว

    The last part was amazing that dijkstra approach first consider the path with low cost no matter if they get you farther from the destination. So this is one disadvantage and also worth to mention that Dijkstra doesn’t work with negative weights. Perhaps I should say it works sometimes but not always.

  • @AnkushPuriSDE
    @AnkushPuriSDE 2 ปีที่แล้ว

    Thank you for this! Made it so simple to understand this algorithm!

  • @CuriousAnonDev
    @CuriousAnonDev ปีที่แล้ว

    the last part was just amazing dude!
    no way i could have found out the that problem/situation on my own

  • @DampeS8N
    @DampeS8N 7 ปีที่แล้ว +4

    Very nice lead in to A*'s heuristic at the end, but I wish you'd called it out specifically there so the interested could go out and learn the next step themselves. (though you did mention it in the video which is good)

  • @kostyapesterew1068
    @kostyapesterew1068 7 ปีที่แล้ว +40

    wait
    why was the search terminated after we found 1st route to end point? isn't it possible that last segment is huge and it isn't the shortest way?

    • @_aullik
      @_aullik 7 ปีที่แล้ว +25

      Cause he messed up :D
      look at 8:20
      The pile at the right is your priority queue. You only ever work at the top most element of this queue. The Q is ordered by distance.
      The mistake they made is that the put "e" at the top of the Q. It should be below "f" tho. This means they would have had to check "d" and "f" first, then go and check "e". Checking "e" means you've finished the algorythm.

    • @Pheatrix
      @Pheatrix 7 ปีที่แล้ว +3

      It shouldn't have been terminated. Normally the search gets terminated when the goal is in the top of the priority list.
      They seem to have forgotten that.

    • @shadowmil
      @shadowmil 7 ปีที่แล้ว

      Because you sorted the nodes you were checking by the cost of getting to that node. Meaning you know that any other paths that might exist will have a higher cost.

    • @_aullik
      @_aullik 7 ปีที่แล้ว

      read my answer. they messed up.

    • @rawrnomnomnomgrrrrrr
      @rawrnomnomnomgrrrrrr 7 ปีที่แล้ว +1

      From what I can see, the routes that went down the roads to the right were both sitting at a value of 9. Since we had already found a path to E that was 7 which is < 9, then the search is stopped for all routes that have a current value > 7.
      In a larger implementation of this algorithm, after a route to the destination is found, then any routes that are currently being searched are discarded if the current value is greater than the best route, as they cannot be the correct answer. (Note: I might be getting this part confused with dynamic programming, but it seems to me that they are essentially the same thing based on this simple example).

  • @jacobdavis000
    @jacobdavis000 5 ปีที่แล้ว +1

    I found this video because I heard the name Dijkstra mentioned in another one of this channel's videos and wondered if it was the same person that invented the Shortest Path Algorithm. So I looked for this video to find out. Glad to find out *was* is what I wanted to see. IIRC: Dijkstra invented the algorithm to show how an early model mainframe computer can be used to solve the shortest path (traveling salesman?) problem. Don't know how accurately I remember it, but It's cool to find out that it is probably one of the oldest computer algorithms ever invented.

  • @perfectlyfantastic
    @perfectlyfantastic 7 ปีที่แล้ว

    very informative , it was like the movie finished in between , it would be lovely to check the second part for the limitations of Dijkstra's Algorithm

  • @Mrslandshark
    @Mrslandshark 7 ปีที่แล้ว

    This is brilliant for Decision 1 revision for Further Maths!

  • @legel93
    @legel93 3 ปีที่แล้ว

    Thank you for the great explanation!

  • @colin-campbell
    @colin-campbell 7 ปีที่แล้ว +107

    Witcher shoutout

  • @MistaMase102
    @MistaMase102 7 ปีที่แล้ว +171

    I got lost at S....

    • @DanBowkley
      @DanBowkley 5 ปีที่แล้ว +21

      Spoken like a true satnav.....

    • @saif0316
      @saif0316 3 ปีที่แล้ว

      Same

    • @aurelia8028
      @aurelia8028 3 ปีที่แล้ว

      Are you proud of your lack of intelligence?

  • @biswajitsingh8790
    @biswajitsingh8790 6 ปีที่แล้ว

    damn this guy is a legend for explaining it in such a simple manner.

  • @shukaizhang2850
    @shukaizhang2850 4 ปีที่แล้ว +139

    Definition of Recursion in the dictionary: See "Recursion"

    • @nq2c
      @nq2c 4 ปีที่แล้ว +6

      error - maximum recursion depth reached

    • @Zmunk19
      @Zmunk19 4 ปีที่แล้ว +8

      if you google "recursion", it says "did you mean recursion?"

    • @MS-il3ht
      @MS-il3ht 3 ปีที่แล้ว +1

      @@Zmunk19 you're right :-)

    • @Yoshi-jr6zn
      @Yoshi-jr6zn 3 ปีที่แล้ว +1

      @@Zmunk19 wow, i tried this

    • @ansismaleckis1296
      @ansismaleckis1296 2 ปีที่แล้ว

      Why use recursion when you can easily get away with loops and stack? In most cases recursion is more "expensive" than itteration.

  • @leonhrad
    @leonhrad 7 ปีที่แล้ว +123

    You made a small mistake. The algorithm terminates once you pop the end node 'E' from the priority queue, because that's when you know that you've found the shortest path to that node. You shouldn't terminate as soon as you've found only one path to the goal.

    • @philipbotha6718
      @philipbotha6718 6 ปีที่แล้ว +17

      The algorithm should terminate in this case because the cumulative cost for all the other paths were already higher than the current path. If you had negative costs, then I believe you should only terminate once 'E" is popped.

    • @bradezard1581
      @bradezard1581 5 ปีที่แล้ว +32

      No, D and F were still on the queue with 6 and E had 7. The path was ultimately the right one, but you can't guarantee that unless you wait until actually popping the goal node. If D or F had a path cost

    • @tombrady7390
      @tombrady7390 3 ปีที่แล้ว +2

      they were just trying to build a overview for the algorithm rather than a comprehensive explanation which i think they did

    • @hil449
      @hil449 ปีที่แล้ว +3

      @@philipbotha6718 Dijkstra doesn't work for negative weights

  • @chandlerjearls476
    @chandlerjearls476 7 ปีที่แล้ว

    Well explained, loved the video

  • @ManuTheGreat79
    @ManuTheGreat79 7 ปีที่แล้ว

    Thanks, this is useful.
    I was thinking of solving the routing of a metro plan (finding the shortest path for a non existing "this should be the Brussels metro" plan) (website with Google Maps), using Dijkstra.

  • @spaghetti185
    @spaghetti185 2 ปีที่แล้ว

    Thanks! That was a really great explaination

  • @anetakahleova5705
    @anetakahleova5705 4 ปีที่แล้ว

    I love you Dr Mike Pound!

  • @douglas.n.m
    @douglas.n.m 7 ปีที่แล้ว

    Amazing explanation!

  • @Richardincancale
    @Richardincancale 7 ปีที่แล้ว

    There's a related algorithm called Floyd's algorithm that calculates the shortest path between all nodes in a network, not just two points, that is used in practice for network design, routing etc.

  • @johnschultz4345
    @johnschultz4345 2 ปีที่แล้ว

    Very nice (other than the termination goof up). One thing I wish you had stated more explicitly is exactly why Dijkstra continues to go down the closest/cheapest paths to the finished set: because there can be no shorter path to those nodes from the source.

  • @snoopy1alpha
    @snoopy1alpha 4 ปีที่แล้ว

    Dijkstra, as I learned it, always searches the whole graph. What you presented is what I would call "A* with heuristic 0" (as you hinted in the final section).
    By searching the whole graph with the, lets call it "complete" Dijkstra, you are actually computing the shortest path to all vertices in that graph. If you start searching at your destination instead of your starting point, you get a data structure that contains the shortest paths from all vertices to your desired destination (assuming you reverse the path(s) from the result). Applied in a routing application (like a GPS system in your car), you do not have to recalculate the route if you took a wrong turn. For this approach being efficient, you would have to pre-calculate a sub-graph to run your Dijkstra on. For real map data you also want to take into account one-way roads and interpret them in reversed orientation. During my studies we actually did exactly that on a map of one of Germany's states. It was amazing. However, we did not do the sub-graph-part which would have allowed us a bigger map (all of Germany or even Europe).

  • @mistervoldemort7540
    @mistervoldemort7540 7 ปีที่แล้ว

    Excellent explanation!

  • @F1refoux
    @F1refoux 7 ปีที่แล้ว

    I wish my teacher explained Dijstra's Algorithm with such clarity... Thanks for this great explanation !

  • @carloswitek
    @carloswitek 7 ปีที่แล้ว

    looking forward to another one ;)

  • @code-dredd
    @code-dredd 5 ปีที่แล้ว

    It's been over a year now. I'd like to see the foreshadowed sequel to this video.

  • @KabyAlkaris
    @KabyAlkaris 7 ปีที่แล้ว +98

    Who else is dutch? Netherlands, represent! Dijkstra mah boii!

    • @jopiekiller
      @jopiekiller 7 ปีที่แล้ว +2

      KabyAlkaris aiiiii

    • @McKon.
      @McKon. 7 ปีที่แล้ว +1

      I had no idea he was saying Dijkstra until I saw the intro.

    • @justinward3679
      @justinward3679 7 ปีที่แล้ว +1

      KabyAlkaris No one cares, go back to your shunting yard.

    • @AhsimNreiziev
      @AhsimNreiziev 7 ปีที่แล้ว +1

      Dutchman here! So very proud of Dijkstra whenever he and his Algorithm come up.

  • @harishravishankar
    @harishravishankar 5 ปีที่แล้ว

    Great demonstration, thanks a lot!

  • @mohamednabil9146
    @mohamednabil9146 7 ปีที่แล้ว

    THIS IS AWESOME I SERIOUSLY FINALLY UNDERSTAND THIS PART 2 PLEASE
    \

  • @hamzanasir1590
    @hamzanasir1590 3 ปีที่แล้ว +1

    Great Explanation Ever Sir 👍👍👍

  • @socksincrocks4421
    @socksincrocks4421 5 ปีที่แล้ว

    Dr. Pound should have his own channel. My new favorite youtube video series after PBS SPACE TIME and EEVBlog.

  • @shelbycollins6116
    @shelbycollins6116 ปีที่แล้ว

    There must be something off with me watching this on my free time on a holiday and enjoying this more than movies or shows

  • @guydht1
    @guydht1 7 ปีที่แล้ว +1

    Do a video about Levenstein distance next! (or other string comparing algorithms)

  • @starchar9378
    @starchar9378 4 ปีที่แล้ว

    I liked this video, I have to tutor this algorithm and this gives me a nice cheeky way to explain it. Thank you.

  • @MrNdb10
    @MrNdb10 7 ปีที่แล้ว

    I enjoy seeing my discrete math class coming into use!

  • @fisslewine1222
    @fisslewine1222 6 ปีที่แล้ว +1

    I'm really liking your tutorials; but would love to see some code as well!

  • @fly7188
    @fly7188 2 ปีที่แล้ว +1

    Pathfinding algorithms always get referenced in the context of spaces and distances but its just as effective when dealing with abstract spaces, ones with dimensions that are defined manually. I imagine there are many problems that could be posed in the context of an abstract space that could be solved with these sorts of algorithms.

    • @hil449
      @hil449 ปีที่แล้ว

      Dynamic programming problems comes to mind

  • @a8lg6p
    @a8lg6p 6 ปีที่แล้ว +2

    Where do they the printer paper from? I remember that stuff from when I was a kid.I didn't know it was still made anymore.

  • @StockDC2
    @StockDC2 7 ปีที่แล้ว +1

    Great explanation. One thing though that would have been nice would have been if you guys showed the weight of all the edges instead of just the edges that a particular node is connected to.

  • @tensevo
    @tensevo 6 ปีที่แล้ว

    LOVE THIS CHANNEL!!!

  • @MeanHacker
    @MeanHacker 7 ปีที่แล้ว +2

    Sean/Brady, could you create an electrical engineering/power engineering channel? Do you have access to professors that teach this material? I think it would be very interesting and would bring a lot of viewers

  • @MatthijsKoelewijn
    @MatthijsKoelewijn 4 ปีที่แล้ว

    Very well explained!

  • @DepressedNOF
    @DepressedNOF 6 ปีที่แล้ว

    Well with the A* you don't have the problem with going in the wrong direction for too long (still possible for a while) because you will keep the realworld distance in your heuristic function.
    And one more thing, correct me if I'm wrong with this, but to be sure about that the found rout from S to E is indeed the shortest you would have to continue Dijakstra until every node is finished. So you can't stop when you found one route from S to E like in the example. In A* you can stop then.

  • @Bakepichai
    @Bakepichai 6 ปีที่แล้ว

    Mike rocks. Please do lot more videos

  • @JohnzillaTheHun
    @JohnzillaTheHun หลายเดือนก่อน

    I was born in the US and my last name is Dijkstra. I majored in computer science before I ended up having to drop out. A few of my professors got excited when taking roll-call, and I had to explain to them that Dijkstra is like the “Smith” of the Netherlands from what I’ve been told. I think I might be related to him though! Just because I’m always trying to figure out the easiest way out of every situation

  • @TransparentLabyrinth
    @TransparentLabyrinth 5 ปีที่แล้ว +78

    I feel like pathfinding algorithms make less sense the more explanations I watch of them. T_T

  • @ahnafs8930
    @ahnafs8930 3 ปีที่แล้ว +1

    just looking at some concepts ill face as a cs student (still in high school), I'm starting to reconsider my options

  • @JBinero
    @JBinero 7 ปีที่แล้ว +35

    What if the last weight was 10,000? Wouldn't it pick that as the fastest route then, despite it being much, much slower than by going through L?

    • @Simon-nx8hq
      @Simon-nx8hq 7 ปีที่แล้ว +43

      Jeroen Bollen Yeah, actually the algorithm only terminates, when the destination node is finally processed, because that means that it is the unprocessed node with the shortest path to it and there cannot be a shorter path.
      They kind of messed up in the video.

    • @TheSlimyDog
      @TheSlimyDog 7 ปีที่แล้ว +14

      Another thing this missed was the fact that when Dijkstra's algorithm terminates, it will find the shortest path to all vertices in the graph from that starting point.

    • @rmsgrey
      @rmsgrey 7 ปีที่แล้ว +19

      +TheSlimyDog
      That depends whether you terminate when you process E (as they should have) or continue until you have processed all nodes. If you're looking for routes from London to Dover, you probably don't care about the best route to Edinburgh.
      What Dijkstra's algorithm does give you is the best route to any processed node - your destination and anywhere cheaper to reach.

    • @TheSlimyDog
      @TheSlimyDog 7 ปีที่แล้ว +6

      I'm sorry, that's correct. You can stop once E is at the top of your priority queue.

    • @rmsgrey
      @rmsgrey 7 ปีที่แล้ว +2

      I should have mentioned earlier that, when deploying it "for real", Djikstra's algorithm is usually run until every available node has been processed, rather than terminating once you reach a designated destination simply because it is so easy to upgrade to A* and it offers such an improvement in performance if you do have a destination to aim for.

  • @alexanderzin
    @alexanderzin 7 ปีที่แล้ว

    Please, do some 3d graphics-related videos with Dr Mike Pound. I know there are already, but mr. Pound explains things so much better for me. Upvote if you agree

  • @trolltothebank
    @trolltothebank 4 ปีที่แล้ว +2

    I didn't know Dijkstra did maths as well as plot for the throne of Redania

  • @artmissgns8315
    @artmissgns8315 2 ปีที่แล้ว

    thanks man, it was amazing

  • @sporkafife
    @sporkafife 7 ปีที่แล้ว

    Hey! I remember Dijkstra's algorithm from A level further maths! Back then I remember it being more complicated... seems really simple now...

  • @reallyWyrd
    @reallyWyrd 7 ปีที่แล้ว

    Brilliant. I have always wondered how Google Maps found routes. I figured something sort of like that because I know a little bit about how routing tables work.
    Now, please explain why traveling salesman is so hard? Is it really all because there are multiple destinations?

  • @a9raag
    @a9raag 7 ปีที่แล้ว +1

    Thank you for correctly pronouncing Dijkstra sick of people calling him DJextra

  • @RedHeroe1
    @RedHeroe1 ปีที่แล้ว

    i just love computers some videos i don't understand a single thing but i love this channel

  • @keithdesouza8859
    @keithdesouza8859 5 ปีที่แล้ว

    Nicely explained. There is still something confusing. The overloaded use of the numbers between the nodes. Is that number, the weight (speed) of the road or is it the distance between nodes?

  • @MrJjjakey
    @MrJjjakey 7 ปีที่แล้ว +15

    This was on my final a few weeks ago.

    • @Sharpienero
      @Sharpienero 7 ปีที่แล้ว +6

      Same. Algorithms class was super fun.

    • @MrJjjakey
      @MrJjjakey 7 ปีที่แล้ว +1

      Mine was Networking, before that I had the algorithm on a CS based Mathematics final the year before.

  • @joemarriage3002
    @joemarriage3002 2 ปีที่แล้ว +3

    Merry AoC day 15, pathfinders!

  • @ADiLetJoldoshbekov
    @ADiLetJoldoshbekov 3 ปีที่แล้ว

    I like the explanation. I found this video the most easily understandable video I have ever seen about the Dijkstra algorithm. Thank you!

  • @umchoyka
    @umchoyka 7 ปีที่แล้ว

    I think you missed a crucial part near the end. You don't stop the algorithm as soon as you hit E. You only stop once E bubbles to the top of the sorted list, otherwise you might miss out on a faster pathway. For example if the connection from G to E had been a very large number, say 100, then the path going to the right would have been faster even though you got to E through G first.

  • @ghiolfanjberg
    @ghiolfanjberg 7 ปีที่แล้ว +1

    Could you do a similar video for Bellman-Ford's algorithm? :D

  • @portblock
    @portblock 7 ปีที่แล้ว

    I find this very interesting, just curious. the number, aka the weight of the path, what if that number was something like: (miles to next hop) + (line of sight distance to destination) + (road work weighting, hazard, etc) ..... Would this kinda account, and stop for going in the wrong direction first because of lower weights (your end scenerio) ??

  • @bhatipradeepsinghsurendras7257
    @bhatipradeepsinghsurendras7257 3 ปีที่แล้ว

    We are maintaining a priority queue so still the E getting inside may or may not be on highest priority. And when E becomes highest priority that means thats the shorter distance bcz other have not reached E and they have distance more that current E distance.
    Correct me if I am wrong.

  • @Maaruks
    @Maaruks 6 ปีที่แล้ว

    this is the best explanation

  • @JohnathanGross
    @JohnathanGross 7 ปีที่แล้ว +16

    The final step is wrong. You can't be sure that the first node to reach the destination is the shortest. What if instead of 2, the path from g to e was 100? It would still be the first to reach it, but would be far from the most efficient. You have to put e in the correct position in the priorities, and only when all shorter paths have been exhausted can you be sure it's the shortest path.

  • @TechXSoftware
    @TechXSoftware 7 ปีที่แล้ว

    I am using this for my games, it is quite complicated then it seems. Its stats basically. I like this algorithm, its so much faster saving CPU power.