def __modularity(status):
    """
    Fast compute the modularity of the partition of the graph using
    status precomputed
    """
    links = float(status.total_weight)
    result = 0.0
    for community in set(status.node2com.values()):
        in_degree = status.internals.get(community, 0.0)
        degree = status.degrees.get(community, 0.0)
        if links > 0:
            result += in_degree / links - (degree / (2.0 * links)) ** 2
    return result
