 So far we've assumed the only property of an edge is the two vertices it links. But in the real world, connections could have variable cost. For example, cities might be linked by trains, but distances can differ. The cost of a ticket can differ. The frequency of trains can differ. We can incorporate these factors by assigning a weight to each edge. Now, we'll still define a geodesic as the shortest path between two vertices, but now the path length incorporates the edge weights. For example, the path ACF goes through two edges, but they're weighty at 10 to 15, so this path has weight 10 plus 15, 25. On the other hand, if we take a longer path, how about ABGF, the weight along this path is 8 plus 6 plus 6, that's 20. So in some sense, this is a shorter path. Now in unweighted graphs, we introduce Dijkstra's algorithm for finding the shortest distance between two points. Unfortunately, when we weight the graphs, we can still use Dijkstra's algorithm. That's unfortunate because solved problems in mathematics deprive us of the chance of finding something new. So imagine recording the shortest known path between two points. As we navigate through the graph, we might be able to update the distances. To illustrate, we'll find the distance from vertex A to all other vertices in the graph. So we'll keep track of our information in a table, and we'll also note both the path and the shortest distance. Now, initially, we know no distances, so we can set all the distances to infinity, or negative 1, or empty set, or something that indicates we haven't found any distances yet. So we'll expand out from A. A is adjacent to vertices B, distance 8, and C, distance 10. Since these are the shortest known paths, we'll record them. That's A to B, with distance 8, and A to C, with distance 10. And we'll also mark the edges to indicate we've checked them. We'll thicken them on our diagram. Now, we expand out from these vertices. From B, we can expand to D, and there is a path ABD of weight 8 plus 4 is 12, and this is the shortest known. So we'll record it. Then we can also go from B to E, and this gives us a path ABE of length 11, and this is the shortest known. And there's a path A to B to G of length 14, and this is the shortest known. We can also expand outward from C. There's a path A to C to E, which has length 22, and this is the shortest known. Wait, no, we already found a path that's shorter. So this path is actually longer than an already known path, and we won't change anything. And finally, there's a path A to C to F with length 25, and this is the shortest known. Now, our endpoints are at E, G, and F, so we'll expand outward from those points. So if we expand from E, the path A to B to E to G has cost 13, which is less than the current shortest path to G, so we replace it. Recalculating. The path A to B to G to F has cost 20, and again, this is less than the current shortest path to F, so we'll replace it. And at this point, we checked all of our edges, and so we're done. Also, since we've updated the actual path, we now know the route that gives us the shortest path. And so if we want to navigate from A to any place else, we know how far it will be, and what route will give us the shortest distance.