1
$\begingroup$

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.

$\endgroup$
4
  • 3
    $\begingroup$ Perhaps you mean to ask if the mapping of vectors to diagonal matrices can be expressed in terms of matrix arithmetic. It can certainly be defined mathematically as a certain linear map from (say) $\mathbb R^n$ to $\mathbb R^{n\times n}$. $\endgroup$
    – hardmath
    Commented Aug 19, 2021 at 19:05
  • $\begingroup$ May you please define the mathematical representation of the map? $\endgroup$
    – Aleph
    Commented Aug 20, 2021 at 4:27
  • $\begingroup$ One (boring) way to define the diag map is via the vectorization map: Take all of the columns of your adjacency matrix and concatenate them vertically to get an $N^2$-vector. Then there's a $N$-by-$N^2$ matrix which takes this matrix and spits out the diagonal elements. $\endgroup$ Commented Aug 20, 2021 at 15:36
  • 1
    $\begingroup$ Using the Hadamard product $(\odot),\,$ the Diag() operator for a vector $v$ can be written in terms of the identity matrix $I$ and the all-ones vector ${\tt1}$ $$\operatorname{Diag}(v) = I\odot\left(v{\tt1}^T\right)$$ It can also be as the dot product of the vector with a special third-order tensor $$\eqalign{{\cal H}_{ijk} &= \begin{cases} 1 \quad&{\rm if\;} i=j=k \\ 0 \quad&{\rm otherwise} \\ \end{cases}\\ {\rm Diag}(v) &= {\cal H}\cdot v \\&= v\cdot {\cal H} }$$ $\endgroup$
    – greg
    Commented Aug 23, 2021 at 16:07

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .