How does Google Maps find the shortest path?

Поділитися
Вставка
  • Опубліковано 11 гру 2024

КОМЕНТАРІ • 105

  • @coolpro211
    @coolpro211 4 місяці тому +173

    The ending caught me off guard 😭

  • @zackieboi
    @zackieboi 4 місяці тому +214

    better idea: construct a massive 20 lane highway from la to new york, and remove the speed limit

    • @yaush_
      @yaush_ 4 місяці тому +17

      If American urban planners could design any way they liked

    • @drooplug
      @drooplug 4 місяці тому +9

      Or a high speed train. 🤷‍♂️

    • @ah244895
      @ah244895 4 місяці тому +5

      ​A high speed train would end up cost more the the GDP of the U.S.

    • @puntersarepeopletoo6
      @puntersarepeopletoo6 3 місяці тому

      ​@@ah244895source: trust me bro

    • @apolluxs
      @apolluxs 3 місяці тому

      @@ah244895train tracks are significantly cheaper than highways regardless of speed

  • @thewombat4377
    @thewombat4377 4 місяці тому +40

    I'm a trucker with many loads from LA to NYC. Simple... take the 40 to the 81 in TN exit 421, then north to the 80 and into NYC. Why? Weather and terrain.

  • @HenrikMyrhaug
    @HenrikMyrhaug 4 місяці тому +74

    Well, you forgot to mention that applying this same path simultaneously from the end point can significantly shorten the time an algorithm takes.

  • @givrally
    @givrally 4 місяці тому +20

    3:48 This is a surprisingly tough thing for students to get past, because in the graph you've drawn it's obvious by look that you have to go through H or G so you should head to those points immediately, but as you've correctly said the algorithm doesn't know that (and also finding such points by an algorithm feels like it would take |V|² time), and students often have trouble with the incomplete information part of programming.
    What I like to do when showing the algorithm in practice is to completely hide the rest of the graph in a kind of "fog of war" : It's not just that you don't know where X is, you don't even know any of the points that aren't X or A until you've been near them. It's easier to do in manim, but you can do that with a piece of paper on a whiteboard. Maybe the shortest path goes through F, but maybe F is a dead end and the rest of the graph goes through B, you don't know unless you try.

  • @emurphy42
    @emurphy42 4 місяці тому +12

    Clarification on A*: The estimating function needs to avoid overestimating the remaining distance, otherwise it might miss a better option. If it underestimates, then it'll still work, just not as fast. (Dijkstra's algorithm is basically A* with an estimating function that just outputs a constant, i.e. "no clue how close we are".)
    Dijkstra's is basically "If a route from X to Y is already worse than another route from X to Y, then don't bother doing anything further with the worse one".
    A* is basically "If a route from X to Y, plus the shortest route that could possibly exist from Y to Z (e.g. as the crow flies for physical distance), is worse than another route from X to W, plus the shortest possible route from W to Z, then set X-to-Y aside for now. We might come back to it if X-to-W turns out to not be as good as we hoped."

  • @nilsboer2390
    @nilsboer2390 4 місяці тому +72

    Even the smartest mathematics can't figure this out 🗣️, shows a video of beetle juice 😂.

  • @danielrinaldi1371
    @danielrinaldi1371 4 місяці тому +4

    As a network engineer we use this algorithm regularly :) cool to see the other applications for dijkstra's algorithm

  • @michael_r
    @michael_r 4 місяці тому +11

    @8:29 Google bought Waze in 2013, 11 years before this video was released. But, I suppose that’s recent in geological time ;)

  • @nothingtoseeherelolkek
    @nothingtoseeherelolkek 3 місяці тому +1

    Freaking awesome! I didn’t get Dijkstra algorithm, but your explanation is clicked with me!

  • @JohnDoe_333
    @JohnDoe_333 2 місяці тому +1

    Very interesting, I've seen a comparable critical path method algorithm in project modeling lecture. But of course you can also use it to navigate from A to B. Nice video and very good explained.

  • @trevinbeattie4888
    @trevinbeattie4888 4 місяці тому +3

    I don’t know why UA-cam recommended this to me, but as a Computer Science nerd I’m glad it did. The topic tangentially reminded me of when I had to find a way to cluster groups of locations in close proximity to each other on a map into a single dot with a count of those locations across different zoom levels, which led me to find and implement the Nearest Neighbor algorithm. I later saw web browser-based implementations that seemed to do the same thing but were much quicker than mine; still don’t know how they managed it.

  • @snoopyloopy
    @snoopyloopy 4 місяці тому +8

    For future reference, "ij" is treated as a single letter in Dutch and it makes the long "I" sound.

    • @GneissDayInnit
      @GneissDayInnit 4 місяці тому +1

      And also I think he says Utrecht, not Tilburg

  • @shaemurphy8193
    @shaemurphy8193 4 місяці тому +5

    By making the path search start from both endpoints you cut the search area by roughly 40%.

  • @christopherdaley5730
    @christopherdaley5730 3 місяці тому +4

    I love the audio. "Yeah I solved this in 20 min. I was chilling with my hot young fiancé. Didn't write anything down. Just knocked it out in my head while doing curls." 😂

  • @ZipplyZane
    @ZipplyZane 4 місяці тому +10

    The obvious answer is that it doesn't. If you know the area, you can always find faster routes. I believe Google prioritizes clear directions.

  • @sydhenderson6753
    @sydhenderson6753 4 місяці тому +5

    They used to have it that if you wanted to go from New York to London you'd swim the Atlantic Ocean.

  • @pawejerzyna5674
    @pawejerzyna5674 4 місяці тому +1

    The best explanation I’ve ever watched

  • @Asterism_Desmos
    @Asterism_Desmos 4 місяці тому +5

    Phenomenal video! An even better ending lol

  • @pajasene
    @pajasene 2 місяці тому +1

    Well made video, thanks

  • @jaylenoschin8189
    @jaylenoschin8189 3 місяці тому +3

    they hired slime mold as a consultant...

  • @bobsieb01
    @bobsieb01 4 місяці тому +9

    There’s no way that man lived his life as a vegan and just recently discovered pepperoni pizza

    • @bbeckwith
      @bbeckwith 4 місяці тому

      Counting Little Ceasers Pizza as NY Style Pizza is also sacrilege

  • @juliansiebert5275
    @juliansiebert5275 Місяць тому +1

    Just had a lecture on route planning at my University and was interested, how close this would be really. Google Maps is for sure not using (plain) Dijkstra's Algorithm, most likely Contraction Hierarchies with some sort of grid-preprocessing to improve adaptation to live traffic

  • @captheobbyist6434
    @captheobbyist6434 3 місяці тому +1

    if you are not tracked, there wont be up to date traffic info.
    if you get tracked, it doesnt use your location to do malicious things like write down your house location to databases, or hiring a hitman to your door.
    this is the tradeoff you have: give your data to third party but it provides you with useful service.
    or you dont give your data at all, and you dont get any service.

  • @petervanderwaart1138
    @petervanderwaart1138 4 місяці тому +1

    This is an adaptation to networks of an older procedure called Dynamic Programming which you should know about if you are interested in this sort of problem.

  • @oop1761
    @oop1761 4 місяці тому +1

    I love your videos, please dont change your style

  • @letsgoloca1846
    @letsgoloca1846 4 місяці тому +3

    This is a great vid

  • @lordkorner
    @lordkorner 3 місяці тому +1

    When i ask google directions in an area i know well ,it doesn't usually find the quickest or best way. Sometimes it brings you on a crazy route just to safe a couple of seconds.

  • @frogandspanner
    @frogandspanner 4 місяці тому +8

    It's pronounced Dijkstra, not Deekstra.
    As an approximation, the Dutch ij is the y of English, so Dykstra would be better.

  • @marble17
    @marble17 3 місяці тому +1

    All of this and i cant find "who asked" like when i heard an argument, people just said "who asked" so i tried to find every possible strategy to find "who asked", but all the strategies i found involved me eating shit
    But after so long, i found this video. I tried the algorithm perfectly but somehow this "who asked" guy is so mysterious i cant even find him on the google maps, so i'll end my journey of finding "who asked" and i hope that people who see my comment can continue my journey on finding "who asked"

  • @malahammer
    @malahammer 3 місяці тому +1

    Thanks for this. I could never find the right way to phrase the question for Google........... "How does Google Maps work?"

  • @yes5421
    @yes5421 4 місяці тому +1

    Loved this vid

  • @vinzdini
    @vinzdini 4 місяці тому +2

    The map provided at 2:27 shows E-G as 4 instead of 7 as mentioned in the video. I continued using that and ended up getting 46 to X. Can someone who did the same pls confirm whether it's correct?

    • @TheUnqualifiedTutor
      @TheUnqualifiedTutor  4 місяці тому +1

      Sorry for that, I tried to copy it onto the whiteboard and must have made a mistake. The whiteboard graph should be consistent with the answers.

  • @borchen0
    @borchen0 4 місяці тому +2

    01:00 I think Dijkstra said 'Utrecht', not 'Tilburg'

  • @TheGreenPig321
    @TheGreenPig321 4 місяці тому +2

    2:10 so this is why it never takes side streets

    • @CalebRoenigk
      @CalebRoenigk 4 місяці тому

      It's also likely they are doing some caching of similar routes too, which means side streets are even less likely to be considered because it's unlikely to do a first search for a route with traffic factored in.

  • @ButchNews
    @ButchNews 4 місяці тому +1

    The shortest distance between two points on the planet is ALWAYS a CURVE... called a Great Circle Route. Highways close to that circle will, most likely, be the fastest/shortest. P.S. I was a naval navigator.

  • @arshamshayan
    @arshamshayan 4 місяці тому +6

    I was edging throughout this video aggressively

    • @TheUnqualifiedTutor
      @TheUnqualifiedTutor  4 місяці тому +10

      🤨

    • @burrdid
      @burrdid 4 місяці тому

      are you still going at it?

    • @arshamshayan
      @arshamshayan 4 місяці тому

      @@burrdid the edge never stop😏🔥😱🙏🙏🙏💀🤠🤠🤠😈🙏😈😈😈😈😃👍☹️👎😔🔫😈

    • @arshamshayan
      @arshamshayan 4 місяці тому

      @@burrdid yessir😈😈😈👺😈👺😈👺😈👺😈👺👺🙏🙏😭😭😭☹️👎😃👍😱🧙‍♀️🔥🧙‍♀️🔥🧙‍♀️🧙‍♀️🔥🙋‍♂️🙋‍♂️🤠🤠🤠🤠

    • @arshamshayan
      @arshamshayan 4 місяці тому

      @@burrdid Absolutely

  • @benkinney8870
    @benkinney8870 4 місяці тому +2

    0:22 A great opportunity was missed to say, "Google will factor in [...] and then tell me to eat shit in under 4 seconds."

  • @Uhhhi-ih8bb
    @Uhhhi-ih8bb 4 місяці тому +1

    This is relevant to me becaude i just ended up olanning a route.
    The other app i was using showed me a direct train route that was

  • @frommarkham424
    @frommarkham424 4 місяці тому +8

    2:45 nikocado avocadooooooooooooooooo

  • @Walkercolt1
    @Walkercolt1 4 місяці тому +2

    Goggle Maps RARELY find "the shortest route" or the EASIEST route and NEVER THE BEST ROUTE!

  • @roygalaasen
    @roygalaasen 4 місяці тому +1

    How obvious it is, it wasn’t until I heard him talk that I realised that Dijkstra was Dutch. OF COURSE! Just look at his name!

  • @frommarkham424
    @frommarkham424 4 місяці тому +2

    0:50 i second this

  • @58Tommy
    @58Tommy 4 місяці тому +1

    So why do map programs give you a bunch of longer options along the way?

    • @TheUnqualifiedTutor
      @TheUnqualifiedTutor  4 місяці тому

      Some are to avoid tolls, and probably just alternatives using different highways I guess. People have different preferences.

    • @CalebRoenigk
      @CalebRoenigk 4 місяці тому

      Another thing to consider is that alternate paths are provided because the maps program can't possibly know every single situation happening on the road. Google collects a lot of data and it's very good at knowing what's happening on the road but the driver ultimately can see stuff that Google can't. Maybe a crash literally happened 1 minute ago and hasn't been reported on Google maps yet. Suddenly that longer route that gets you off at the next exit might help you avoid that traffic. It's just about providing users with choices.

  • @patfre
    @patfre 4 місяці тому +2

    I saw a video not long ago that actually explains how and why google map probably doesn’t use dijkstra algorithm and it’s due to loops if you add extra data to use this is the case for electric vehicles. If you try and find how much power it will use to get from point A to point B with chargers in between so you might think to make the weight of those negative however this will cause a loop where it keeps going lower and lower meaning the distance according to the algorithm would be negative infinity which is not possible and the only way known to avoid this is to use the old algorithm. For most other cases it probably does actually use it but I thought I would just mention it.

    • @palmberry5576
      @palmberry5576 4 місяці тому +1

      Well it’s only meant for positive weights

  • @environmentaldataexchange3906
    @environmentaldataexchange3906 3 місяці тому +1

    @2:42 Nikocado Avocado! He used to be a skinny frutarian.

  • @BeatlesBowieKrimson
    @BeatlesBowieKrimson 3 місяці тому +1

    Beetlejuice at 0:44 !!!!! How can i send all of my money to you?

  • @bbeckwith
    @bbeckwith 4 місяці тому +1

    47 hours? Fastest route NY to LA is 25 hours 39 minutes...

  • @fifiwoof1969
    @fifiwoof1969 4 місяці тому +1

    Dijkstra's algorithm?

  • @ntdscherer
    @ntdscherer 4 місяці тому +2

    You seem to be saying "shortest" and "fastest" as though they're the same thing.

    • @zarfmouse
      @zarfmouse 4 місяці тому

      The algorithm is the same in either case. It's just a matter of whether the metric between nodes is time or distance. You can run this with a bunch of time metrics rather than distance metrics and you will find the fastest path.
      The algorithm could also find the cheapest path if you used cost metrics instead of time or distance. The algorithm finds the path that minimizes some metric. That metric can be anything that relates to the connection between 2 nodes on the graph.

    • @ntdscherer
      @ntdscherer 3 місяці тому

      @@zarfmouse Right, it's just a little distracting since the algorithm Google Maps uses by default is shortest time, not shortest distance.

    • @zarfmouse
      @zarfmouse 3 місяці тому

      @@ntdscherer In computer science this is always called a "shortest path" algorithm no matter what metric is used. This is part of the "abstraction" concept discussed earlier in the video. The abstraction is finding the shortest path through a graph with metric weighted edges. The real life outcome is a fastest route, shortest route, cheapest route, or other optimized route depending on the metrics that the graph edges were weighted with.

    • @ntdscherer
      @ntdscherer 3 місяці тому

      @@zarfmouse Yeah that's fair

  • @alo1236546
    @alo1236546 4 місяці тому +1

    The old way follow the gas stations

  • @sevipapadopoulou6494
    @sevipapadopoulou6494 4 місяці тому

    2:27

  • @alaminumfoil
    @alaminumfoil 4 місяці тому +2

    "click this video now if you want to see more, and f-"

  • @Xpurple
    @Xpurple 4 місяці тому +1

    Apple also tracks you for the same reason.

  • @sdspivey
    @sdspivey 4 місяці тому +2

    They do not find the shortest distance or fastest route. They find a short enough route. Checking *all* path possibilities would take too long for the webpage to load.

    • @roygalaasen
      @roygalaasen 4 місяці тому +1

      Google algorithm doesn’t, but Dijkstra’s algorithm does find the shortest path, given enough time. It could potentially take the age of the universe, though, as you are saying.

  • @alphalunamare
    @alphalunamare 4 місяці тому +2

    It's like rats v humans in a maze. Rats actually use Dyksra's algorithm, Humans (with a sense of direction) use the latter heuristic method :-)

  • @kenmore01
    @kenmore01 4 місяці тому +1

    The best solution is to not start at LA or go to NY.

  • @haneytr3s
    @haneytr3s 4 місяці тому +1

    What happens if you tell Google Maps to eat shit.

  • @stevecooper6473
    @stevecooper6473 4 місяці тому +1

    Why do Brits always say "Los AngeleEEs?" Are they all from LondOOn? From Britaane?

    • @TheUnqualifiedTutor
      @TheUnqualifiedTutor  4 місяці тому

      I never noticed before, but I guess you're right. Los Angelis

  • @MissPiggyM976
    @MissPiggyM976 4 місяці тому +1

    Too fast...

  • @soulGrafitti
    @soulGrafitti 4 місяці тому +2

    Except for the body shaming an excellent presentation.

  • @DrJRaven
    @DrJRaven 4 місяці тому

    It doesn’t. Google maps are totally inaccurate. Example, is a city south of Sydney, google has a street running right through houses. As far as shortest distance, that’s a great joke 😂

  • @vsctutorials8355
    @vsctutorials8355 4 місяці тому +1

    Noice

  • @FloridaMan02
    @FloridaMan02 4 місяці тому +3

    Shortest and quickest are not even remotely related... sheesh

    • @zarfmouse
      @zarfmouse 4 місяці тому +2

      Same algorithm, different path weights.

  • @danpreston564
    @danpreston564 4 місяці тому +4

    Fat jokes? Really?

  • @sugandesenuds6663
    @sugandesenuds6663 4 місяці тому +2

    You ask me whats the shortest path from LA to New york? Go to LAX, get on a plane, fly to new york, and then eat shit :D

  • @emilioturbay667
    @emilioturbay667 4 місяці тому +2

    Poorly explained. The shortest path is not always the fastest one and the presenter continuously uses both terms as the same.

    • @panda4247
      @panda4247 4 місяці тому

      But it is the same if you want it to be the same.. depends on the abstraction you use.
      In graph theory it is called the "shortest path", and what does it mean in the real world depends only on what are the values (weights) that you assign to tue edges.
      It can be distance in km, it can be distance in minutes, it can price or the route (factoring in the terrain that affects your consumption + tolls)...

  • @nabeelahmed6358
    @nabeelahmed6358 4 місяці тому +2

    first!

  • @chriswharton
    @chriswharton 4 місяці тому +1

    You’re very smart . I can’t speak maths, but I can spell.