Sum of the degrees of second neighbours of a vertex in a graph

2k Views Asked by At

The question is: "Using only matrix formalism find the vector $\pmb{v}$ whose element $i$ is the sum of the degrees of vertex's $i$ second neighbours".

My attempt:

Let $A$ be the adjacent matrix of the graph. The vector $\pmb{k}$ whose elements are the degree of the vertices is $\pmb{k}=A\cdot\pmb{1}$ where $\pmb{1}$ is a column vector off all ones. Now, to find the sum of the degrees of the second neighbours I need a proper matrix to rearrange and sum the elements of the vector $\pmb{k}$. For instance if I want instead the sum of the degrees of the first neighbours the proper matrix is the adjacent matrix. Indeed $A\cdot\pmb{k}$ is the vector whose element $i$ is the sum of the degrees of vertex $i$-th.

I tried to use a matrix similar to: $A^2-diag(\pmb{k})$, but, of course, it will not work due to repetitions and loops.

Thanks