Graph Theory37 sections · 1633 units
Open in Course

CSES 1671 Shortest Routes I - Recognizing Dijkstra

(Single-source, non-negative)

The problem asks for single-source shortest paths. Weights are positive. N is large (10510^{5}), so Floyd-Warshall would take 101510^{15} operations and time out. BFS will not work because weights vary.

Bellman-Ford would work but runs in O(NM)O(NM), slower than Dijkstra's O((N+M)logN)O((N + M) \log N). Dijkstra is the clear choice. Non-negative weights, single-source, large graph. Use an adjacency list and a min-heap for the implementation.