from typing import Dict
from typing import Tuple


def get_dendogram_bounds(dg: Dict, data_range: int) -> Tuple[int, int]:

    """

    function to calculate bounds and reduction factor for plotting dendograms

    :param dg: dictionary output from scipy dendogram calculation
    :param data_range: length of data in dendogram clustering direction
    :return: the max data length in clustering direction and reduction factor to match dendogram
        calculation to data
    """

    mins, maxs = zip(*((min(cls), max(cls)) for cls in dg['icoord']))
    dg_max = min(mins) + max(maxs)
    reduction_factor = dg_max / data_range
    return dg_max, reduction_factor