Guided Lesson Notes
Understanding Adjacency Matrix
Adjacency Matrix focuses on relationships, reachability, paths, cycles, connectivity, and optimization over edges. An adjacency matrix stores edge information in a grid, making edge checks fast but using more space for sparse graphs.
The mental model is this: draw vertices as dots and edges as connections; then decide whether direction, weight, or capacity matters. That picture matters because it tells the student what information is available immediately and what must be searched, stored, or recomputed.
The core invariant is that visited, distance, parent, component, or flow arrays must match what has actually been discovered so far. If a solution cannot state that rule, the code may still run on a sample input but fail on edge cases.
A strong implementation usually uses adjacency lists or matrices, queues, stacks, priority queues, union-find, and repeated edge relaxation. The goal is not just to memorize an API; the goal is to know why each operation is allowed and what it costs.
In competitive programming, Adjacency Matrix tends to appear when the problem mentions roads, networks, prerequisites, components, shortest paths, spanning costs, or dependency order. Spotting that signal is often the difference between a nested-loop solution and an efficient one.
