def assign_x_coordinates(self, tree, x_start, width):
    num_leaves = len(list(tree.leaves()))
    x_scale = (width / (num_leaves + 1))
    node_x_coord_map = {}
    leaf_x = x_start
    for root in tree.roots:
        for u in tree.nodes(root, order='postorder'):
            if tree.is_leaf(u):
                leaf_x += x_scale
                node_x_coord_map[u] = leaf_x
            else:
                child_coords = [node_x_coord_map[c] for c in tree.children(u)]
                if (len(child_coords) == 1):
                    node_x_coord_map[u] = child_coords[0]
                else:
                    a = min(child_coords)
                    b = max(child_coords)
                    assert ((b - a) > 1)
                    node_x_coord_map[u] = (a + ((b - a) / 2))
    return node_x_coord_map
def assign_x_coordinates(self, tree, x_start, width):
    num_leaves = len(list(tree.leaves()))
    x_scale = (width / (num_leaves + 1))
    node_x_coord_map = {}
    leaf_x = x_start
    for root in tree.roots:
        for u in tree.nodes(root, order='postorder'):
            if tree.is_leaf(u):
                leaf_x += x_scale
                node_x_coord_map[u] = leaf_x
            else:
                child_coords = [node_x_coord_map[c] for c in tree.children(u)]
                if (len(child_coords) == 1):
                    node_x_coord_map[u] = child_coords[0]
                else:
                    a = min(child_coords)
                    b = max(child_coords)
                    assert ((b - a) > 1)
                    node_x_coord_map[u] = (a + ((b - a) / 2))
    return node_x_coord_map