xposition = function(curr, xlo, xhi) -- return the left margin to position a node at if curr.children == nil or #curr.children == 0 then return xlo end if #curr.children == 1 then return xposition(Nodes[curr.children[1]], xlo, xhi) end local total_boundaries = 0 local curr_boundary = xlo for child_idx = 1,#curr.children-1 do local child_id = curr.children[child_idx] local child = Nodes[child_id] curr_boundary = curr_boundary + 620 * child.ntracks total_boundaries = total_boundaries + curr_boundary end local centerx = total_boundaries / (#curr.children-1) return centerx - 620/2 end