def stubs(nodes, relns):
    """Return the list of stub nodes."""
    # start from every node, drop any node that is ever a peer or a provider
    stubs = set(range(0, nodes))
    for ((u, v), relp) in relns.items():
        if relp == "cust_prov":
            stubs.discard(v)
        elif relp == "peer_peer":
            stubs.discard(u)
            stubs.discard(v)
        elif relp == "prov_cust":
            stubs.discard(u)
    return list(stubs)