Level 2 NCEA Networks - Shortest Path (Dijkstra’s Algorithm) — Transcript
Full transcript
- 0:01kia ora and welcome to a lesson on level
- 0:03two networks specifically the shortest
- 0:06path and more specifically using
- 0:08dijkstra's algorithm to find the
- 0:10shortest path and
- 0:12they'll potentially be arguments as to
- 0:14the pronunciation of that name but it's
- 0:16the name the way i've always been told
- 0:18to pronounce your name so that's how i'm
- 0:20using it today if you have an
- 0:22alternative method
- 0:23which is more correct
- 0:25good on you um
- 0:27but that's that's how i've been taught
- 0:29to say it i apologize if it is
- 0:31incredibly wrong
- 0:33okay
- 0:33so
- 0:34first of all
- 0:36what is the shortest path well the
- 0:37shortest path
- 0:38basically says if you want to go from
- 0:40one node
- 0:41to another node
- 0:43what is the shortest way you can
- 0:44navigate this network to get from that
- 0:47node
- 0:48to the other node okay so if i want to
- 0:50go from a to g there's lots of different
- 0:52ways i can go from a to g
- 0:54as shown in here i can go very basic
- 0:56just around the outside i can go
- 0:58crazy all over the place if i really
- 1:00wanted to but obviously we're trying to
- 1:03find the shortest version of that so
- 1:04that's why we're going to use dijkstra's
- 1:06algorithm
- 1:08so looking at dijktras algorithm it says
- 1:11give the starting node a value of zero
- 1:13and this is an abridged version of
- 1:15dijkstra's algorithm without an extra
- 1:17bit of work but it's all we're going to
- 1:18need for our purposes so we're going to
- 1:21use this so give a starting node a value
- 1:24of 0.
- 1:25it then says to put a box around the
- 1:27node you are at
- 1:29and then travel off the edges from node
- 1:31and label the connect nodes with value
- 1:33of travel
- 1:34if there is no
- 1:35current value or the value that is there
- 1:38is higher than the new value and that
- 1:40will sound very confusing for now but
- 1:42i'll hopefully try and explain that a
- 1:43bit better whilst we're going through it
- 1:45step 4 says looking at the network
- 1:47select the next smallest valued node
- 1:49that is not boxed if this is the end
- 1:51node stop and expect inspect which root
- 1:54creator this value if not repeat from
- 1:56step two so you keep bouncing back step
- 1:58two until you're at the end basically
- 2:00so let's put this into practice because
- 2:03those written instructions aren't
- 2:04necessarily going to be the easiest
- 2:05thing to start so if i wanted to go from
- 2:07a to
- 2:09g
- 2:11how will that look so we're going to go
- 2:13to our start point right a and we're
- 2:15going to say at a we are zero because
- 2:17we've not traveled anywhere
- 2:19okay the next step says put a box around
- 2:21the node you're at so i'm going to put a
- 2:22box around the zero
- 2:25and then step three says travel off the
- 2:27edges
- 2:28um from the node and label connect knows
- 2:30the value of travel if there's no
- 2:32current value of a value
- 2:34there is ha sorry the value
- 2:37there is a higher than the new value
- 2:39okay
- 2:40so from a i can go to b which is six
- 2:43there is no number there so i'm going to
- 2:45write the number six
- 2:46and from a
- 2:49i can also go to c
- 2:51and there's no value there so i'm going
- 2:52to write the number seven those are the
- 2:54only two places i can go
- 2:56from a
- 2:58okay so i've done step three now and
- 3:00i've labeled them because there's no
- 3:01value step four says looking up network
- 3:04select the next smallest valued node
- 3:06that is not boxed
- 3:07assuming you're not selecting the end
- 3:09node which is going to be g so i'm not
- 3:10going to worry about that clause until
- 3:12we get to g
- 3:13so
- 3:15we've done all the ways from a we're now
- 3:17looking at a diagram again there's no
- 3:19information on these nodes okay there's
- 3:21no value here so we're only considering
- 3:23these two nodes and their values and
- 3:26we're going to select the smallest of
- 3:27those two values which is the six
- 3:31and we're going to go back to step two
- 3:32which says put a box around that number
- 3:34so we'll put a box around b
- 3:36okay and now we're going to inspect from
- 3:38b so we're now at b we're going to look
- 3:40at
- 3:41all the different places we could go
- 3:42from b so there's no point going back to
- 3:44a because we've already put box there
- 3:46distance was zero however from b we
- 3:48could go to c
- 3:50so we say
- 3:51six plus six
- 3:53which is twelve total
- 3:55is twelve smaller number seven
- 3:58if it's not smaller than seven we're not
- 4:00going to do anything
- 4:02uh if it was smaller than seven would
- 4:04cross out the seven and write our new
- 4:06number but 12 is not smaller than seven
- 4:07so we're not going to do that
- 4:09so from b we can also then travel to d
- 4:13which is in total eight because six plus
- 4:16two is eight there's no number there so
- 4:18i'm gonna write the number eight there
- 4:21and then from b we can also travel to e
- 4:24which is six plus five which is eleven
- 4:26again there's no number there so we're
- 4:28going to write the number there
- 4:2911 and now we have gone to every place
- 4:33we can go to
- 4:34from b so there's no point looking at
- 4:37that one this one wasn't smaller than
- 4:39seven so we didn't do anything this one
- 4:41had no number this one had no number so
- 4:43we wrote the total value
- 4:45so far traveled
- 4:47okay
- 4:48now we've done all that we're now going
- 4:50to look at our diagram again and we're
- 4:52going to look at the places where we
- 4:54have numbers eleven eight and seven and
- 4:56we're going to select the smallest of
- 4:58those three which is down at c
- 5:00seven and we're gonna put a box around
- 5:03it
- 5:03once we've put our box around it we're
- 5:05gonna say from c where can we go so
- 5:07there's no point going to a because
- 5:08there's already a box there's no point
- 5:10going to b because there's already a box
- 5:12however from c we could go to d so what
- 5:14is seven plus three well seven plus
- 5:16three is ten is it smaller than eight no
- 5:19so we're not going to write the ten down
- 5:21so we're gonna leave that alone
- 5:22but we can go from c to f
- 5:257 plus 6 is 13 there's no number there
- 5:28so we're going to write the number 13.
- 5:31okay
- 5:31now we've considered all the paths from
- 5:33c
- 5:35we're going to go back to looking at
- 5:36these numbers and choose our smallest so
- 5:39the smallest here
- 5:40is this eight
- 5:42okay so this number here is our smallest
- 5:45be eight okay
- 5:47so we're going to put a box around our
- 5:49eight
- 5:51and now we're going to look at all the
- 5:52places we can go from d so we can go
- 5:54from d to e which is far more which will
- 5:57take us 12. it's not smaller than 11 so
- 6:00we're not going to choose it
- 6:02from d to f
- 6:03that's eight plus five which is 13 which
- 6:06is the same as what's already there so
- 6:08it doesn't matter which one of those two
- 6:09we're going to choose okay
- 6:11but there's two ways of getting to about
- 6:1313
- 6:14and that's the only other place because
- 6:16the other paths are back to boxes
- 6:19okay so now we've considered all the
- 6:20places we can go from d we're going to
- 6:22go back to looking at the nodes where
- 6:24there's a value 11 and 13 choosing the
- 6:26smaller of a 2
- 6:28which is v11
- 6:30and saying from here where can we go
- 6:32well we can either go down to f which is
- 6:3411 plus 3
- 6:36which is 14
- 6:38that's bigger so we're not going to
- 6:39change this at all
- 6:41and and we e to g
- 6:43is 7 more so that is 18
- 6:46okay that's
- 6:47gonna stay there because it had no value
- 6:50and now we've done all the places we can
- 6:51go from e
- 6:55and by the way this will probably if
- 6:57you've just been watching this non-stop
- 6:58you're probably sitting here going i
- 7:00kind of lost it about two minutes ago
- 7:02because he just kept talking
- 7:04pause the video go back maybe check
- 7:07the steps but it's just following the
- 7:09same algorithm i'm just constantly going
- 7:11to here to here going back to two
- 7:14from two to three too far to back to two
- 7:16okay
- 7:18now i'm at this point here where again
- 7:19i'm selecting up these two the smallest
- 7:22numbers still 13
- 7:24so i'm going to select my 13
- 7:27okay
- 7:28and i'm going to say from f there's only
- 7:29one place i can go because i everywhere
- 7:31else is already boxed which is to g
- 7:34is 13 plus 8 smaller than 18 no because
- 7:37it's 21 so 21 is bigger
- 7:39so that's our end
- 7:42and now
- 7:43at our final node which is 18 which is
- 7:46actually where we're ending up
- 7:48that is the value which will take us to
- 7:52there okay so this is going to be 18 so
- 7:54we're going to put a box around it
- 7:57unfortunately in this one i didn't get
- 7:59an opportunity to show you crossing out
- 8:01a value i'm replacing it with a new
- 8:03value but if
- 8:05when i inspected one of these edges if
- 8:07it had been smaller the total value then
- 8:10i would have crossed out the value that
- 8:12was already there and written my new
- 8:13value to replace it okay
- 8:16so
- 8:18so the final step said looking at the
- 8:20network select smallest value node of
- 8:21the box if this nodes um if this is the
- 8:24endnote stop and inspect which route
- 8:26created this value so now we're going to
- 8:27do the inspect which route created this
- 8:29value
- 8:30so from g i'm going to work backwards
- 8:33okay so i'm going to say
- 8:35which of these edges makes sense so g is
- 8:3818. if i was to go eight back
- 8:41that would take me to ten
- 8:43however this value here is not ten
- 8:46so
- 8:48let's have a look at the other place i
- 8:49can go and grow from g is seven back
- 8:51this way eighteen seven back is 11. so
- 8:54this is
- 8:56part of my path okay because it makes
- 8:58sense 18
- 9:00minus 7 gave me 11. so this is true
- 9:05from a
- 9:06if i was to look going along these edges
- 9:09which one of these three situations
- 9:11actually makes sense well eleven minus
- 9:13three is not thirteen
- 9:15eleven minus four is not seven but
- 9:18eleven minus five is six
- 9:20so this path here
- 9:23this five path is part of my shortest
- 9:26path
- 9:27and then from b i go is six minus two
- 9:30eight no six minus two is four
- 9:33is six minus six seven no it is zero and
- 9:36is six minus six zero yes it is so this
- 9:39must also be part of my path
- 9:42so my shortest path from a to g
- 9:44would go
- 9:46a
- 9:47to b
- 9:48to e
- 9:49to g
- 9:51and is equal to
- 9:5318
- 9:54kilometers minutes dollars depending on
- 9:58whatever units you are using to describe
- 10:00your network
- 10:02and i
- 10:05thought i couldn't add for a second
- 10:07but no i i i can add 6 out of 5 out of 7
- 10:10is 18. so that is true um so that is
- 10:13dytra's algorithm to find the shortest
- 10:16path okay you can find the shots path
- 10:19via inspection however the maximum you
- 10:21can get for shots pathfire inspection is
- 10:23achieved so if i just looked at this
- 10:25network and going oh yeah i can see
- 10:26abegs it's going to be the shyness at
- 10:2818.
- 10:29i can save that and you'll get achieved
- 10:32and there are other methods of a van
- 10:34dijkstra's algorithm there's a tree
- 10:35diagram method
- 10:36uh however from merit and excellence
- 10:39there's actually a bit more explanation
- 10:40that needs to go into it than dijkstra's
- 10:42and i find dijkstra's overall the
- 10:45easiest
- 10:46of the methods to use for those higher
- 10:49awarded grades as well as just from
- 10:52making sure you don't make a mistake
- 10:54okay because the tree diagram method can
- 10:56be a bit fiddly and easy to make
- 10:58mistakes on however it does kind of make
- 11:00a bit more sense
- 11:01dijkstra's is very kind of abstracty
- 11:04however it does get you to the answer a
- 11:07bit easier okay
- 11:09so
- 11:11this is nitrous algorithm shots path and
- 11:13you can use it for any network to find
- 11:14the shortest path
- 11:16hopefully this kind of makes sense if
- 11:18not maybe re-watch it go a bit slower
- 11:21and
- 11:22there if you're wanting more videos on
- 11:24network there's a video on
- 11:25traversability as well as a video on the
- 11:28minimum spanning tree for you to use
- 11:30hopefully this is helpful
- 11:32uh good luck and bye
About this transcript
This page contains the full transcript of Level 2 NCEA Networks - Shortest Path (Dijkstra’s Algorithm) by Maths is Maths, generated from the public captions YouTube serves with the video. The transcript has 2,138 words across 341 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.