Beispiel #1
0
def updateFlipNode(root,rectangles,dictionary):
	newRoot = deepcopy(root)
	#newRoot = root

	r = random.randint(0,1)

	if r==0 and newRoot.left is not None:
		utils.flipNode(newRoot.left)
	elif newRoot.right is not None:
		utils.flipNode(newRoot.right)

	# Adjust parent node dimensions
	if newRoot.type == '|':
		newRoot.w = newRoot.left.w + newRoot.right.w
		newRoot.h = max(newRoot.left.h,newRoot.right.h)
	else:
		newRoot.h = newRoot.left.h + newRoot.right.h
		newRoot.w = max(newRoot.left.w,newRoot.right.w)

	rectangles = utils.getRectanglesFromRoot(newRoot)
	utils.resetRectangles(rectangles)
	utils.updateTreeDimensions(newRoot)

	return newRoot
Beispiel #2
0
def costWithLamdasFromRoot(root, costParameters):
	# construct new rectangles
	rectangles = utils.getRectanglesFromRoot(root)
	#print("Length of rectangles = " + str(len(rectangles)))
	return costWithLamdas(rectangles, costParameters)