Concepts20
Johnson's Algorithm
Johnson's Algorithm computes all-pairs shortest paths on sparse graphs by first removing negative edges via reweighting, then running Dijkstra from every vertex.
Bellman-Ford Algorithm
BellmanโFord finds single-source shortest paths even when some edge weights are negative.
Dijkstra - Variations and Applications
Dijkstraโs algorithm can be adapted to track the second shortest path by keeping the best and second-best distances per vertex.
Topological Sort - DP on DAG
Topological sort orders vertices of a directed acyclic graph (DAG) so every edge goes from earlier to later, which is perfect for dynamic programming (DP).
Topological Sort
Topological sort orders the nodes of a directed acyclic graph (DAG) so every edge points from left to right in the order.
Multi-Source BFS
Multi-source BFS explores an unweighted graph starting from several sources at once to compute the minimum distance to any source for every vertex.
Centroid Decomposition - Distance Queries
Centroid decomposition splits a tree into levels by repeatedly removing a centroid so that each remaining component is at most half the size.
Queue and Deque
A queue is a First-In-First-Out (FIFO) line where you add at the back and remove from the front in O(1) time.