[APPLAUSE] >> Okay, so you've got the code to solve this part of the assignment, but here's where things get really interesting. Because we can do it the way I described. But if you have an adjacency matrix representation, there's actually a really cool way to solve the two-hop neighbor problem, not for a single vertex, but in fact for all the vertices in the graph. And this is using matrix multiplication. So I'm going take our matrix and I'm going to represent it a little bit more mathematically. So instead of a table I'm going to make a matrix that looks like this. And it turns out that if I square this matrix, the resulting matrix is a matrix who's entries represent the two-hop neighbors for each vertex in the graph. That's pretty cool. So lets take a look at how this works on this example. So here's the matrix I want to square, I'll just write the same matrix next to each other, and then I'm going to go through and perform matrix multiplication. And, you may know how matrix multiplication works, you may have forgotten how matrix multiplications works. I always forget how matrix multiplication works, so I have to look it up every time. But the way we do matrix multiplication is we're gonna take for example here, the top row in the first matrix and do a dot product of that top row with the first column in that second matrix. Then we're going to put that in the upper left corner of our resulting matrix. So there's our dot product we have 0x01x, 1x0+1x0+ 0x0. So what's gonna go into that first entry is just a zero. And if we think about that, that means that there are zero ways to get from node zero back to node zero in two hops. And that's true, you can't get back to node zero in two hops if you start there. Moving over a column. Now, this is going to be the next entry over, it's the dot product. It's the top row, with the second column. That's going to give us one. And, if we think about what's happening here, what we're saying is that there is a path, starting in node zero, that takes two hops and reaches node one. And, in fact, we saw that path at the beginning of this series of videos. If we keep going, we see that there is no two-hop paths from node zero to node two. There's a one-hop path, but if you go two-hops, you will away from node two. And then, something really cool happens with this last entry. Because that value of the stop product here is actually equal to two. And what that's saying is that there are actually two paths from zero to three in two hops and those are the paths that we saw at the beginning. The path across the top through one and the path across the bottom through node two. We can continue to fill in this table and we get the values that you see here. And if you look at this matrix, you'll see that it is in fact all of the two hop has from all the vertices to every other vertex in this graph. So that's really cool, it's cool for couple of reasons. One reason is, we did it for all vertices at the same time. So we didn't have to just loop through and you every single one separately like your method would do. We could do them all in just one fell swoop. The other reason this is really cool is that matrix multiplication is a very well studied problem. It's extremely important to be able to do matrix multiplication fast for a lot of different problems. So there are a lot of algorithms and hardware as well as that are optimized to do matrix multiplication extremely, extremely fast. So with those advances, with those algorithms, with that hardware, we can solve this problem very, very quickly when we have our graph in an adjacency matrix representation. All right, that's just for your enjoyment, you don't have to implement matrix multiplication for your assignment. Though you can if you like to have a general solution. And we hope that you have fun with this part of the assignment.