Fixing code to take into account newest networkx version.