Lab 2.2
Block Matrices and Graphs
Lab goal
Explain how np.block joins compatible rectangles and why one entry of a squared adjacency matrix counts length-two walks.
- Block matrices
- Block multiplication
- Adjacency matrix
- Walk counts
Code extensionThe full notebook continues to Schur complements, block inverses, longer walks, and bipartite reordering.
Key ideas
Terms you will use
- Compatible blocks
X = [[A, B], [C, D]] Blocks in one block row need the same height; blocks in one block column need the same width.
- Block multiplication
top-left = A E + B G The usual row-by-column rule still applies when each entry is itself a compatible matrix.
- Adjacency power
(adj²)ᵢⱼ = # two-step walks Entry (i,j) of G² counts the length-two walks from vertex i to vertex j.
Lab 2.2 · Guided example
See blocks and graph walks with small matrices
This trace keeps two ideas from the notebook—block arithmetic and adjacency powers—and removes the larger inverse and 8-vertex examples.
Select a line to see its action, array shape, and concrete operation.
The four definitions become one 3×3 matrix.
Two ideas, one rule
Matrix multiplication combines compatible rows and columns, whether we view them as blocks or graph connections.
Reveal to compare.
X.shapenot stored → ?A complete square matrix.