00:02
Ok, i've got a graph here, and i started to set up the table.
00:08
I'm going to list the vertices, a, b, c, d, e, f, g, z.
00:20
And then we're going to start with vertex a.
00:26
And its shortest path to a would be 0.
00:30
And the rest we can label as infinite, just to get us started.
00:40
And i'm leaving a little bit of space in my column there, because i know those will be changing.
00:46
So i'll be crossing those values out and listing the new values.
00:52
Ok, so what we do now is we start with a, and we look at its neighbors.
01:00
Its neighbors are b and c.
01:06
So we can find the shortest distance from b to a and c to a.
01:11
So b, we can see it's 4.
01:13
So i'll cross out my previous value and put 4.
01:17
That's coming from vertex a.
01:20
So i'll write a there.
01:22
And c, that distance we can see is 3.
01:27
That's coming from vertex a.
01:31
Ok, so now i can check vertex a off as being visited.
01:37
It's now a visited vertex.
01:41
Ok, so now i look at my unvisited vertices and find the one with the shortest path to a.
01:51
So that would be c.
01:55
So now i'm going to visit c.
01:57
I'll put a red dot on c.
02:02
And i'm going to look at c's unvisited neighbors.
02:07
So that would be b, d, and e.
02:11
So if i go to b, what's the distance from a to b via c there? well, c, we know the shortest path is 3.
02:25
So we're just going to be adding these values from the neighbor to c.
02:30
So i'll be adding 2 to 3.
02:32
I'll be adding 3 to 3.
02:34
I'll be adding 6 to 3.
02:36
Starting with b, 2 plus 3 is 5.
02:42
Now, notice that that's bigger than what i already have for b.
02:47
So i'm not going to replace b.
02:50
Let's look at d.
02:53
So 2 plus 3, or sorry, 3 plus 3 is 6.
03:00
I don't have enough room to write there.
03:03
It's getting cut off.
03:12
Let me, can i scroll a little bit? no, i can't make space myself.
03:17
So for d, it's 3 plus 3, which is 6.
03:22
I'll put a 6 there.
03:23
That was coming from c.
03:27
Ok, now let's look at vertex e.
03:31
So the value from c was 3.
03:35
And then i add the 6.
03:37
And i get 9 for e.
03:40
So i can put 9 for e.
03:42
And that was coming from c.
03:45
Ok, i've marked all of c's neighbors.
03:48
So i can check that off as being visited.
03:54
Ok, so now i'm going to look at the unvisited vertex with the smallest path to a.
04:02
So that'd be b.
04:03
It's got a 4.
04:05
So now i'm going to visit b.
04:07
I'll make that red.
04:09
Let's look at its unvisited neighbors.
04:11
That would just be d.
04:15
So b, to get from b to d, that's going to be 4.
04:18
That's the number from my table.
04:20
Plus 5...