Combinatorics & Graph Theory
Counting principles, graphs, and a live breadth-first search.
Combinatorics: counting structured objects.
- Multiplication / addition principle: total = product (resp. sum) of independent (disjoint) options.
- Binomial coefficients: $\binom{n}{k} = n! / (k!(n-k)!)$ counts $k$-subsets of an $n$-set.
- Inclusion–exclusion: $|A \cup B| = |A| + |B| - |A \cap B|$, generalizing to many sets.
A graph $G = (V, E)$ is a pair of vertices and edges. Connectedness, paths, cycles, trees, and bipartiteness are core concepts. Euler's formula for connected planar graphs: $V - E + F = 2$.
Algorithms: BFS explores by layers (shortest path in unweighted graphs); DFS traverses depth-first (used for topological sort, SCCs). Dijkstra extends BFS to non-negative weights; Bellman–Ford handles negative weights.
Interactive: BFS shortest path
Click a vertex to set it as the source; vertices light up as they're visited, with their distance.