# Network science: How to calculate assortativity (Pearson's correlation) coefficient for this small network?

Let $A$ denote a weighted, directed network, where the weights in the rows are the out-degrees, and weights in the columns are the in-degrees:

$A$ = \begin{bmatrix} 0 & 0 & 0 \\ 1 & 0 & 2 \\ 1 & 0 & 0 \end{bmatrix}

Here is the formula that I would like to use (the notation isn't clear to me):

$$r= \frac{\sum_{jk}(jk(e(j,k)-q(j)q(k)))}{\sigma_{q}^2}$$

According to my R function (igraph), $r = - 0.5$ .

My problem is that I don't understand what the variables denote in this formula. I read the book Networks by Newman, and it provided the same 'minimalist' information about the equation.

I tried to calculate the correlation by links or by the sum of the in- and out-degrees of the nodes, however, my results were different. Let $x$ be the vector of out-edges, and $y$ the vector of in-edges: $x=(1,1,0), y=(0,0,2)$, then $corr(x,y)=-1$.

Could someone show me a step-by-step solution, please?

• Scroll down a bit in that Wikipedia article and you will note that for directed networks, you have to distinguish between an in- and out-assortativity. – Wrzlprmft Nov 4 '17 at 8:51
• Hi @Wrzlprmft. I've already scrolled down. Do you have any more tips? – Übel Yildmar Nov 4 '17 at 12:33