A weighted graph attaches a number to every edge, standing for cost, distance or time. Some graphs use it for capacity instead. An unweighted graph treats all edges as equal, so every edge counts as one step. Weights change the question from "how few edges" to "how little total cost".
That matters because the cheapest route is often not the shortest by edge count. Three short highway segments can beat one long back road. Weights are miles or minutes on a map, and latency or price on a network.
Breadth-first search finds fewest-edge paths, but it ignores weights and gives wrong answers once they exist. You then need a weight-aware method like Dijkstra. So first ask whether edges carry a real cost, because that decides which algorithm is correct.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
If every edge has the same weight, do you still need Dijkstra?With equal weights, total cost grows with edge count, so BFS stays correct and runs in linear time without a heap.
How do you store edge weights in an adjacency list versus a matrix?List entries become neighbor-weight pairs. Matrix cells hold the weight, with a no-edge marker like infinity, since 0 can be a real weight.
What you can say
A weighted graph puts a number on every edge, usually a cost, a distance or a time, and sometimes a capacity.
In an unweighted graph every edge counts as one step, so the question is how few edges get you from A to B.
Weights change that to how little total cost, and the cheapest route often isn't the one with the fewest edges. Three short highway segments can beat one long back road.
On a map the weights are miles or minutes, and on a network they're latency or price.
BFS finds fewest-edge paths, but it ignores weights, so once they exist it can return the wrong path and you need something weight-aware like Dijkstra.
So the first thing I ask is whether the edges carry a real cost. If they don't, BFS is correct and cheaper, and if they do, BFS gives wrong answers.
Weak answers to avoid
Defines the term and stopsThe question asks why it matters. Say that weights turn fewest edges into lowest total cost, and that this decides which algorithm returns the right path.
Uses BFS for shortest paths on weighted edgesBFS counts edges, not cost, so it can return a path with fewer edges and a higher total. Name a weight-aware method like Dijkstra.
Says Dijkstra works for any weightsDijkstra assumes no edge weight is negative. State that limit, and mention Bellman-Ford for graphs with negative edges.
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.