According to https://iopscience.iop.org/article/10.1209/0295-5075/89/49901, the local assortativity of a node in a graph is the node contribution to the total assortativity in a network. This can be calculated with the next equation:

$\rho = \frac{j(j+1)(\overline k-\mu_q)}{2M\sigma_q^2}$

where $j$ is the excess degree of a particular node and $\overline k$ is the average excess degree of its neighbors and $M$ is the number of edges in the graph. $q$ is the excess degree distribution of the graph.

In the paper cited above (as also Wikipedia it says about local assortativity), the sum of local assortativity of all vertex, $p_i$, is equal to the assortativity of the whole graph denoted by $r$. This is:

$r = \sum \rho_i$ ,


$r = \sum_{jk} \frac{jk(e_{jk}-q_j q_k)} {\sigma_q^2}$ , where $e_{jk}$ refers to the joint probability distribution of the remaining degrees of the two vertices.

To test such equality, I'm using as a "toy example" a graph with 4 vertex and 3 edges that exhibits a star topology, i.e. one vertex in the center with three vertexes in the periphery. Therefore, in a vector notation, with the central vertex as the first element in the vector, the degree values of the graph is $[3,1,1,1]$ and the vector that represents the excess degree of the vertexes is $[2,0,0,0]$, that is, the degree of the each vertex minus one. Is clear that the assortativity of my graph is $-1$ because this is clearly a graph where all links are between nodes of a different degree.

My problem is that my python implementation of the sum of all $\rho_i$ gives a different result compared with the estimation of $r$ using the method assortativity_degree of the package $igraph$(https://igraph.org/python/doc/igraph.GraphBase-class.html#assortativity_degree). As I expected, the value of $r$ that gives $igraph$ is $-1$

This is the output of my code where all calculated can be observed:

First, I show the general values to calculate the denominator in the equation of $\rho$:

Degree distribution values = [3,1,1,1]
Excess degree distribution values = [2,0,0,0]

Calculus of values in denominator for all addends:
M = 3
mu of remaining degree distribution =  0.5
Variance of remaining degree distribution =  0.75

Then, I make the calculus of values for each numerator in a loop for each local assortativity ...

This is the output for the local assortativity of the central node:

vertex id = 0
vertex degree = 3
vertex excess degree = 2
neighbors excess degrees =  [0, 0, 0]
avg(vertex_degree_neighbours) = 0.0

rho(0) = 2(2 + 1)(0 - 0.5) / (2)(3)(0.75) = -3.0  /  4.5  =  -0.6666666666666666

This is the output for the local assortativity of the next periphery node:

vertex id = 1
vertex degree = 1
vertex excess degree = 0
neighbors excess degrees =  [2]
avg(neighbors excess degrees) = 2.0

rho(1) = 0(0 + 1)(0 - 0.5) / (2)(3)(0.75) = 0.0  /  4.5  =  0.0


and, as $\rho_1$ = $\rho_2$ = $\rho_3 = 0$ then

summation of local assortativities =  -0.6666666666666666
igraph assortativity r =  -1.0
Diff =  0.33333333333333337

I suspect that my code is poorly implementing some concept of the $\rho$ equation, but I can't find the issue.

  • $\begingroup$ This comment just to mention that if in my toy example, the only local assortativity that counts is from the central node and the result must be -1, then my doubts points to the interpretation of what the excess degree distribution is and for so, the calculation of the expected value and the variance (standard deviation raised to 2) on such distribution. $\endgroup$ – Fernando Barraza Sep 6 '19 at 2:24

The issue is related to the estimation of the mean and the variance of the excess degree distribution that is part of the equation. As is shown in the output of the implementation above, those metrics are being calculated based on the vector of excess degrees but in the paper is clear that the excess degree distribution 𝑞 truly follow this formula:

$$q(k) = \frac{(k+1)p(k+1)}{\overline k}$$ where $p$ is the probability of a node be of degree k and $\overline k$ is the degree average.

Making the respective changes then the result of estimation by both methods is the same:

Sum of local assortativities =  -1.0
igraph assortativity =  -1.0
Diff calculation =  0.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.