def pereira_index_unweighted(p, q):
    """
    Given two Partition objects, 
    computes and returns the Tavares-Pereira et al. (2009)
    distance index (unweighted). 
    """
    num_disagree_edges = 0

    for e in p.graph.edges():
        x = min(e)
        y = max(e)
        px = p.assignment[x]
        qx = q.assignment[x]
        py = p.assignment[y]
        qy = q.assignment[y]

        num_disagree_edges += ((px == py and not(qx == qy)) or (not(px == py) and qx == qy))

    num_edges = p.graph.number_of_edges()
    assert(q.graph.number_of_edges() == num_edges) # Need to have same underlying graph
    
    return 1. / num_edges * (num_disagree_edges), num_disagree_edges, num_edges