Skip to content

Graphs

  • Representations: adjacency matrix, adjacency list, edge list, incidence matrix
  • Traversals: BFS (shortest path in unweighted graphs), DFS (cycle detection, topological sort)
  • Shortest paths: Dijkstra (non-negative weights), Bellman-Ford (negative weights, cycle detection), Floyd-Warshall (all pairs)
  • Minimum spanning trees: Kruskal (union-find), Prim (priority queue)
  • Topological sort: Kahn's algorithm (BFS), DFS-based
  • Strongly connected components: Tarjan's algorithm, Kosaraju's algorithm
  • Network flow: Ford-Fulkerson, Edmonds-Karp, max-flow min-cut theorem
  • Bipartite matching: Hungarian algorithm, Hopcroft-Karp