An adjacency matrix represents a graph with a |V|×|V| table. Cell (i,j) records the edge from vertex i to vertex j: its weight for weighted graphs, or true/false or 1/0 for unweighted graphs. section 14.1.1
Reading a matrix
For vertices V1–V4, a 1 in row V1 and column V2 indicates an edge from V1 to V2. A 0 indicates no such edge. The displayed example has edges V1→V2, V1→V3, and V2→V4. section 14.1.1
The representation makes edge insertion and deletion constant-time operations. Listing outgoing or incoming edges requires scanning a row or column, taking O(|V|). Its fixed table uses O(|V|²) space, so it can waste memory when few possible connections exist. section 14.1.1
Browse the concrete 4×4 matrix to connect row-column positions with directed edges. section 14.1.1
Choose an adjacency matrix mainly for dense graphs or workloads requiring fast direct edge updates. For most other graph problems, an adjacency list generally uses less space. section 14.6 section 14.1.1







