def inter_community_edges(G, partition):
 return nx.quotient_graph(G, partition, create_using=nx.MultiGraph()).size()

def inter_community_edges ( G , partition ) : return nx . quotient_graph ( G , partition , create_using = nx . MultiGraph ( ) ) . size ( )
returns the number of inter-community edges according to the given partition of the nodes of g .