# Why does multiplying with the inverse degree matrix normalize the adjacency matrix?

I was studying graph neural networks with this blog and came across a part where it states that if we want to row-normalize the adjacency matrix of a graph, then we multiply the inverse degree matrix to it as such:

$$A \rightarrow D^{-1}A$$

I’ve tried this myself with a toy example, and this does render the rows of the adjacency matrix $$A$$ to sum to $$1$$.

Perhaps this is due to my lack of understanding of basic graph theory, but why is this so? Is there a particular relationship between the degree and adjacency matrices of graphs?

Row $$i$$ of $$A$$ contains $$1$$'s in columns $$j$$, where node $$i$$ is connected to node $$j$$, everywhere else it has zeros. So the sum of the row is exactly the number of edges of node $$i$$. Now $$D$$ is a diagonal matrix which contains in entry $$(i, i)$$ exactly the number of edges of node $$i$$. So if you compute $$D^{-1} A$$, you effectively multiply each row of $$A$$ with the inverse of its sum.