Vectorized form of a Graph's Degree matrix?

127 Views Asked by At

A Graph's diagonal Degree matrix, $D$ is typically defined as

$$ D_{ii} = \sum_{j} A_{ij} $$

i.e., each i-th diagonal of the Degree matrix is the sum of the i-th row of matrix $A$ (the Adjacency matrix).

I am wondering if it is possible to write a vectorized form for $D$, using $A$ and possibly some other constant matrix.

The only thing I can come up with is

$$D_{ii} = A_{i\cdot} * \boldsymbol{1}$$

Where A_{i\cdot} is a row vector, the i-th row of $A$, and $\boldsymbol{1}$ is a column vector of 1's. I can't figure out how to generalize the expression for $D$ sucintly, and I'm not sure if it possible. Any hints?

2

There are 2 best solutions below

2
On BEST ANSWER

You can simply define $D$ as $D = \text{diag}\left(A \boldsymbol{1}\right)$ where $\boldsymbol{1} $ is a column vector of 1s.

0
On

Let $I$ be the identity matrix and $J$ the all-ones matrix, both the same size as $A$.

Then the degree matrix is $\,D = I\odot(AJ)\;$ where $\odot$ denotes the elementwise/Hadamard product.

It's not a particularly efficient formula for calculating $D\,$ but it does lend itself to algebraic manipulation for theoretical purposes.