本文整理汇总了Python中Node.Node.assignment方法的典型用法代码示例。如果您正苦于以下问题:Python Node.assignment方法的具体用法?Python Node.assignment怎么用?Python Node.assignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node.Node
的用法示例。
在下文中一共展示了Node.assignment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createChildNodes
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import assignment [as 别名]
def createChildNodes(self, sortedVarValues, currentNode, currentVariable):
newChildren = []
for value in sortedVarValues:
# make new node and set currentNode as the parent
newChild = Node(currentNode)
# grab the assignment from the parent node
newChild.assignment = copy.deepcopy(currentNode.assignment)
# newChild.printAssignment()
newChild.currentcsp = copy.deepcopy(currentNode.currentcsp)
# grab the value we wanted to change and put it in the assignment of the new child
newChild.assignment[currentVariable.name] = value
# add the child to the list, we will use this list later
newChildren.append(copy.deepcopy(newChild))
# now that we've made all the children, set their parent nodes, and altered their assignment
# with the proper value, now we're gonna set all their right sibling pointers
#basically, this pointer makes printing the tree easier
i = 1
for child in newChildren:
child.rightSibling = newChildren[i]
if i is len(newChildren):
child.rightSibling is None
currentNode.children = newChildren
return newChildren