def compute_class_prior(links):
    """Compute class prior probability: P(C)"""
    p2p_count, p2c_count, c2p_count = 0, 0, 0
    for link, rel in links.rel.iteritems():
        if rel == 'p2p':
            p2p_count += 1
        elif rel == 'p2c':
            p2c_count += 1
        else:
            c2p_count += 1
    sum_class = p2p_count + p2c_count + c2p_count
    return map(lambda x: float(x)/sum_class, (p2p_count, p2c_count, c2p_count))