Пример #1
0
def partition(tree):
    '''Measures the distribution of sections
       to the children subtrees at each bifurcation point.
       Partition is defined as the max/min number of sections
       between the children subtrees of a bifurcation point.

       Returns:
           List of partition for each bifurcation point.
    '''
    def partition_at_point(bif_point):
        '''Partition at each bif point.'''
        n = float(n_sections(bif_point.children[0]))
        m = float(n_sections(bif_point.children[1]))
        return max(n, m) / min(n, m)

    return [partition_at_point(i)
            for i in tr.ibifurcation_point(tree)]
Пример #2
0
def n_bifurcations(tree):
    """
    Return number of bifurcations in tree
    """
    return sum(1 for _ in tr.ibifurcation_point(tree))