Graph Theory37 sections · 1633 units
Open in Course

Introducing Weights

Edge weights and their meanings

In a Weighted Graph, every edge has a "weight" (or cost). It could represent:

1.1. Distance in kilometers (Google Maps).

2.2. Time in minutes (flight connections).

3.3. Cost in dollars (shipping routes).

4.4. Latency in milliseconds (network routing).

BFS finds shortest paths when all edges have weight 11. With varying weights, you need Dijkstra. It always picks the closest unvisited node, ensuring you process nodes in order of their shortest distance from the source.