#NEWLINE# def intra_community_edges( G , partition ) : #NEWLINE# #INDENT# 'Returns the number of intra-community edges according to the given\n    partition of the nodes of `G`.\n\n    `G` must be a NetworkX graph.\n\n    `partition` must be a partition of the nodes of `G`.\n\n    The "intra-community edges" are those edges joining a pair of nodes\n    in the same block of the partition.\n\n    ' #NEWLINE# return sum ( ( G . subgraph ( block ) . size ( ) for block in block ) )