Obtaining the degree matrix from the adjacency matrix

adjacency matrixmatrices

I was unable to find a mathematical operation for obtaining the degree matrix from the adjacency matrix of a given graph.

For a graph $G = (V,E)$, let $A$ be the adjacency matrix of $G$ and let $D \in \mathbb{R}^{{|V|}\times |V|}$ be the (diagonal) degree matrix, $D = \mbox{diag} \left( A 1_{|V|} \right)$, where $1_{|V|}$ is the vector of all-ones of dimension $|V|$. More specifically, I want to know if we can mathematically define the $\mbox{diag}(\cdot)$ operation.

Best Answer

As with any linear mapping, the function $F:\mathbb R^n \to \mathbb R^{n\times n}$ that sends a vector $\vec v = (v_1,\ldots,v_n)$ to a diagonal matrix with those entries:

$$ F\, \vec v = \begin{pmatrix} v_1 & & 0 \\ & \ddots & \\ 0 & & v_n \end{pmatrix} $$

is uniquely determined by its action on a basis. With a suitable choice of notation we can turn such a definition into a "formula".

Recall the standard ordered basis for $\mathbb R^n$, namely row vectors:

$$ \textbf e_1 = (1,0,\ldots,0), \ldots, \textbf e_n = (0,\ldots,0,1) $$

We can then define our linear mapping as a sum:

$$ F(v_1,\ldots,v_n) = \sum_{k=1}^n v_k \textbf e_k^T \textbf e_k $$

Note that the product of column vector $\textbf e_k^T$ and the row vector $\textbf e_k$ gives a diagonal $n\times n$ matrix with $1$ in the $k$th diagonal position (and zeros elsewhere). Therefore the summation of these terms gives a diagonal matrix supplying exactly the specified diagonal entries.