#NEWLINE# @ require_partition #NEWLINE# def coverage( G , partition ) : #NEWLINE# #INDENT# 'Returns the coverage of a partition.\n\n    The *coverage* of a partition is the ratio of the number of\n    intra-community edges to the total number of edges in the graph.\n\n    Parameters\n    ----------\n    G : NetworkX graph\n\n    partition : sequence\n        Partition of the nodes of `G`, represented as a sequence of\n        sets of nodes. Each block of the partition represents a\n        community.\n\n    Returns\n    -------\n    float\n        The coverage of the partition, as defined above.\n\n    Raises\n    ------\n    NetworkXError\n        If `partition` is not a valid partition of the nodes of `G`.\n\n    Notes\n    -----\n    If `G` is a multigraph, the multiplicity of edges is counted.\n\n    References\n    ----------\n    .. [1] Santo Fortunato.\n           "Community Detection in Graphs".\n           *Physical Reports*, Volume 486, Issue 3--5 pp. 75--174\n           <http://arxiv.org/abs/0906.0612>\n\n    ' #NEWLINE# intra_edges = intra_community_edges ( G , partition ) #NEWLINE# total_edges = G . number_of_edges ( ) #NEWLINE# return ( intra_edges / total_edges )