All language subtitles for 02_1-3-dijkstras-algorithm.en

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,690 --> 00:00:04,640 In the previous section, we looked at planning problems on grids and 2 00:00:04,640 --> 00:00:08,970 concluded that we could apply a grass fire algorithm or breadth-first search to 3 00:00:08,970 --> 00:00:12,800 the resulting graph to find the shortest path between start node and a goal node. 4 00:00:13,930 --> 00:00:16,980 Turns out that a similar algorithm can actually be applied to find the shortest 5 00:00:16,980 --> 00:00:21,010 path to arbitrary graphs with non negative edge weights. 6 00:00:21,010 --> 00:00:24,730 Let's consider the problem where we want to go from one town or village to another. 7 00:00:25,920 --> 00:00:27,795 We modeled this problem with a graph. 8 00:00:27,795 --> 00:00:30,190 With nodes correspond to the villages and 9 00:00:30,190 --> 00:00:32,070 the edges correspond to the roadways between them. 10 00:00:33,170 --> 00:00:35,850 We associate a number with each of the edges in the graph 11 00:00:35,850 --> 00:00:39,000 to indicate the distance associated with each of those roads. 12 00:00:39,000 --> 00:00:42,790 For concrete let's think of these distances as miles. 13 00:00:44,050 --> 00:00:44,980 In other words, 14 00:00:44,980 --> 00:00:50,390 our goal is to find the shortest path from node A to node E through the graph. 15 00:00:50,390 --> 00:00:53,660 Or in other words, our goal is to find a path for 16 00:00:53,660 --> 00:00:57,060 the start node to the end node that minimizes the sum of the weights or 17 00:00:57,060 --> 00:00:59,870 costs associated with the edges along that path. 18 00:01:01,440 --> 00:01:06,280 We begin by marking our starting node with a distance value of zero. 19 00:01:06,280 --> 00:01:10,880 Here we use a red color to indicate that this node has been visited or marked. 20 00:01:10,880 --> 00:01:15,660 We then mark each of the nodes that are adjacent to node A, in this case, 21 00:01:15,660 --> 00:01:18,360 nodes B, D, and F. 22 00:01:18,360 --> 00:01:21,900 We use the blue color to indicate that these notes are now 23 00:01:21,900 --> 00:01:23,490 part of a list that we're currently considering. 24 00:01:24,900 --> 00:01:28,085 Notice that we've associated a number with each of these nodes. 25 00:01:29,180 --> 00:01:33,690 For instance, D now has a value of two, indicating that that's the shortest path 26 00:01:33,690 --> 00:01:38,390 that we currently know about from the start node to that node D. 27 00:01:38,390 --> 00:01:42,450 On the next iteration, we end up visiting node B 28 00:01:42,450 --> 00:01:47,310 because that has the shortest associated distance of all of the blue nodes. 29 00:01:47,310 --> 00:01:50,230 In visiting all of these neighbors, 30 00:01:50,230 --> 00:01:54,400 we discover our route node C, which is of length 8, 31 00:01:54,400 --> 00:01:59,850 indicating that this is currently the shortest path that we know of to C. 32 00:01:59,850 --> 00:02:02,700 On the following iteration, we visit node D. 33 00:02:04,180 --> 00:02:05,920 When we visit all the neighbors of D, 34 00:02:05,920 --> 00:02:10,320 we notice that there is now a shorter path to node C, via node D, and 35 00:02:10,320 --> 00:02:14,950 we update the distance associated with node C to five, to reflect this fact. 36 00:02:14,950 --> 00:02:21,144 On the following iteration, we add node F And in visiting 37 00:02:21,144 --> 00:02:26,260 each of its neighbors, we discover a shorter path to node G, as shown here. 38 00:02:26,260 --> 00:02:28,010 Next iteration, we add node C. 39 00:02:29,670 --> 00:02:31,180 And in visiting each of its neighbors, 40 00:02:31,180 --> 00:02:36,140 we notice that we've now discovered a path to our destination node E. 41 00:02:36,140 --> 00:02:38,619 And we have an associated distance of six. 42 00:02:40,110 --> 00:02:44,930 On the final iteration, we end up adding node E to our graph and 43 00:02:44,930 --> 00:02:48,320 discovering there is in fact a path from node A to node E. 44 00:02:49,470 --> 00:02:53,756 Here's an outline for Dijkstra's algorithm and pseudo code. 45 00:02:53,756 --> 00:02:59,545 Notice that we associate two attributes with each of the nodes in the graph, 46 00:02:59,545 --> 00:03:02,628 like distance value and a parent field. 47 00:03:02,628 --> 00:03:08,750 Which we end up using to discover a path from our destination back to our source. 48 00:03:08,750 --> 00:03:11,270 On each iteration of the algorithm, 49 00:03:11,270 --> 00:03:16,180 we choose the node in the list with the smallest associated distance values. 50 00:03:16,180 --> 00:03:21,410 We update the neighbors of that node, as we described earlier. 51 00:03:21,410 --> 00:03:23,520 Once the destination is removed, 52 00:03:23,520 --> 00:03:28,440 we can recover a path to the start by starting at the destination node and 53 00:03:28,440 --> 00:03:34,200 repeatedly moving from each node to its parent until we arrive at the start node. 54 00:03:34,200 --> 00:03:37,220 The computation complexity of this algorithm is related to the number of 55 00:03:37,220 --> 00:03:39,409 nodes and the number of edges in the graph. 56 00:03:40,590 --> 00:03:44,630 A naive version of this algorithm can be implemented with a computational 57 00:03:44,630 --> 00:03:47,970 complexity that grows quadratically with the number of nodes in the graph. 58 00:03:49,320 --> 00:03:53,966 By implementing the sorted list of nodes more cleverly with a data structure known 59 00:03:53,966 --> 00:03:58,343 as a priority queue, we can actually reduce the computational complexity to 60 00:03:58,343 --> 00:04:02,004 a term that grows more slowly, as shown in the second equation. 61 00:04:02,004 --> 00:04:07,198 So we see that the Dijkstra's procedure is a bit more expensive than grass fire but 62 00:04:07,198 --> 00:04:11,350 only by a term that grows logarithmically in the number of nodes. 63 00:04:12,590 --> 00:04:15,660 The basic reason that Dijkstra's algorithm works 64 00:04:15,660 --> 00:04:20,090 is that we end up marking nodes based on their distance from the start node. 65 00:04:21,950 --> 00:04:27,560 That is whenever we mark a node, color it red in our example, 66 00:04:27,560 --> 00:04:32,000 we can be sure that there is no shorter path to that node 67 00:04:32,000 --> 00:04:35,650 from the start node via any of the nodes that we haven't marked yet, 68 00:04:37,060 --> 00:04:40,114 given the fact that our edge weights are in fact non-negative. 69 00:04:41,840 --> 00:04:45,097 Take a minute to convince yourself that this procedure does, in fact, 70 00:04:45,097 --> 00:04:46,254 find the shortest path.6645

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.