def get_cardinality(graph, *identifiers):
    """
    Get the cardinality of all nodes in given FactorGraph of DiscreteFactors.

    """

    cards = []
    for node in graph:
        if node.phi.variable in identifiers:
            cards.append(node.phi.cardinality(node.phi.variable))

    return cards