calculate modularity networkx