Matrices are Graphs

The single most undervalued fact of linear algebra: matrices are graphs, and graphs are matrices. Encoding matrices as graphs is a cheat code, making complex behavior simple to study. twitter

The graph-matrix correspondence.

Each row is a node, and each element represents a directed and weighted edge. The element in the 𝑖-th row and 𝑗-th column corresponds to an edge going from 𝑖 to 𝑗.

Why is the directed graph representation beneficial for us? For one, the powers of the matrix correspond to walks in the graph. Take a look at the elements of the square matrix. All possible 2-step walks are accounted for in the sum defining the elements of A².

If the directed graph represents the states of a Markov chain, the square of its transition probability matrix essentially shows the probability of the chain having some state after two steps.