Skip to main content
`Ctrl`+`K`

# partition_quality

partition_quality(G, partition)

  Returns the coverage and performance of a partition of G.

  The coverage of a partition is the ratio of the number of intra-community edges to the total number of edges in the graph.

  The performance of a partition is the number of intra-community edges plus inter-community non-edges divided by the total number of potential edges.

  This algorithm has complexity \(O(C^2 + L)\) where C is the number of communities and L is the number of links.

  Parameters:
    G NetworkX graph
    partition sequence

      Partition of the nodes of `G`, represented as a sequence of sets of nodes (blocks). Each block of the partition represents a community.

  Returns:
    (float, float)

      The (coverage, performance) tuple of the partition, as defined above.

  Raises:
    NetworkXError

      If `partition` is not a valid partition of the nodes of `G`.

  Notes

  If `G` is a multigraph;

    - for coverage, the multiplicity of edges is counted

    - for performance, the result is -1 (total number of possible edges is not defined)

  References

  [1]

  Santo Fortunato. “Community Detection in Graphs”. Physical Reports, Volume 486, Issue 3–5 pp. 75–174 <https://arxiv.org/abs/0906.0612>