def hierarchyToNumber(digits, b):
    """ Function to convert an address in the hierarchy to a number.

    Parameters
    ----------
    digits, tuple of ints:
        The address in the hierarchy.
    b, int:
       The order of the base graph for the hierarcical product.

    Returns
    -------
    count, int:
        A number which can be used to index the hierarchy.
    """

    count = 0
    for pos, d in enumerate(digits):
        count += d*(b**pos)
    return count