Calculating the assortativity coefficient of a graph