def _F_hyperedge_tail_cardinality(H, F):
    """Returns the result of a function F applied to the set of cardinalities
    of hyperedge tails in the hypergraph.

    :param H: the hypergraph whose tail cardinalities will be
                    operated on.
    :param F: function to execute on the set of cardinalities in the
            hypergraph.
    :returns: result of the given function F.
    :raises: TypeError -- Algorithm only applicable to directed hypergraphs

    """
    if not isinstance(H, DirectedHypergraph):
        raise TypeError("Algorithm only applicable to directed hypergraphs")

    return F([len(H.get_hyperedge_tail(hyperedge_id))
             for hyperedge_id in H.get_hyperedge_id_set()])
Returns the result of a function F applied to the set of cardinalities
    of hyperedge tails in the hypergraph.

    :param H: the hypergraph whose tail cardinalities will be
                    operated on.
    :param F: function to execute on the set of cardinalities in the
            hypergraph.
    :returns: result of the given function F.
    :raises: TypeError -- Algorithm only applicable to directed hypergraphs