Graph Theory37 sections · 1633 units
Open in Course

The Decision Tree

(Four questions to ask)

Before coding, ask yourself four questions:

1.1. Are all edges weight 11? Use BFS.

2.2. Are weights non-negative? Use Dijkstra.

3.3. Are there negative weights? Use Bellman-Ford.

4.4. Do you need all-pairs distances and N400N \leq 400? Use Floyd-Warshall.

Each question narrows your options. Answer them in order. The first matching condition determines your algorithm choice. If none match cleanly, combine techniques or look for problem-specific structure to exploit.