当前位置: 首页>>代码示例>>Python>>正文


Python Node.add_child方法代码示例

本文整理汇总了Python中node.Node.add_child方法的典型用法代码示例。如果您正苦于以下问题:Python Node.add_child方法的具体用法?Python Node.add_child怎么用?Python Node.add_child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在node.Node的用法示例。


在下文中一共展示了Node.add_child方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_lookahead_nodes

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import add_child [as 别名]
def add_lookahead_nodes(pnodes, gate_dist):
	"""If a previous (legitimate) node has only an END child, add a "missing" child"""
	for pnode in pnodes:
		if len(pnode.children) == 1 and not pnode.missing:
			missnode = Node(pnode.obj)
			missnode.missing = True
			missnode.dist = gate_dist
			missnode.add_child(Node(consts.END))
			pnode.add_child(missnode)
开发者ID:Oceanlab90,项目名称:OceanEddies,代码行数:11,代码来源:lookahead.py

示例2: add_child

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import add_child [as 别名]
    def add_child(self, child):
        """Add a child SyntacticNode to a SyntacticNode.

        Args:
        child: the child SyntacticNode
        """
        if self._type == SyntacticNode.TERMINAL:
            raise ValueError("Terminal node cannot have child node")
        type_utils.assert_type(child, SyntacticNode)
        Node.add_child(self, child)
开发者ID:thenghiapham,项目名称:p_tree_kernel,代码行数:12,代码来源:syntactic_node.py

示例3: create_full_tree

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import add_child [as 别名]
    def create_full_tree(depth):
        """ Creates a tree using the full method with depth `depth`.
            Returns the root node.

        Args:
            depth: int

        Returns:
            Node instance
        """
        if depth == 0:
            # Generate a leaf node
            terminal = Function.random_terminal()
            node = Node(terminal)
            return node
        else:
            # Generate an intermediate node
            func = Function.random_function()
            node = Node(func)

            for _ in range(func.arity):
                node.add_child(TreeMethods.create_full_tree(depth - 1))
            return node
开发者ID:mlberkeley,项目名称:genetic-algs,代码行数:25,代码来源:tree_methods.py

示例4: Node

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import add_child [as 别名]
# Tree 1
n0 = Node('n0')
n1 = Node('n1')
n2 = Node('n2')
n3 = Node('n3')
n4 = Node('n4')
n5 = Node('n5')
n6 = Node('n6')
n7 = Node('n7')
n8 = Node('n8')
n9 = Node('n9')
n10 = Node('n10')
n11 = Node('n11')

n0.add_child(n1)
n1.add_child(n2)
n1.add_child(n3)
n2.add_child(n4)
n3.add_child(n5)
n4.add_child(n6)
n6.add_child(n7)
n2.add_child(n8)
n8.add_child(n9)
n9.add_child(n10)
n10.add_child(n11)

print '---Heights'
print 'n0', n0.get_height()
print 'n2', n2.get_height()
print 'n4', n4.get_height()
开发者ID:icedingo,项目名称:NCSS-2012,代码行数:32,代码来源:nodetest.py

示例5: add_room

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import add_child [as 别名]
 def add_room(self, room, coordinate):
     Node.add_child(self, room)
     self.map_grid[coordinate[0]][coordinate[1]] = room
开发者ID:peterhriser,项目名称:PythonTextAdventure,代码行数:5,代码来源:gamemap.py

示例6: Node

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import add_child [as 别名]
from node import Node

# Nodes
theropodiaNode = Node("Theropodia")

ceratosauriaNode = Node("Ceratosauria")
tetanuraeNode = Node("Tetanurae")

coelophysoiNode = Node("Coelophysoi")
abelisauroiNode = Node("Abelisauroi")

coelurosauriaNode = Node("Coelurosauria")

tRexNode = Node("T-Rex")
eendNode = Node("Eend")

# Build tree
theropodiaNode.add_child(ceratosauriaNode)
theropodiaNode.add_child(tetanuraeNode)

ceratosauriaNode.add_child(coelophysoiNode)
ceratosauriaNode.add_child(abelisauroiNode)

tetanuraeNode.add_child(coelurosauriaNode)

coelurosauriaNode.add_child(tRexNode)
coelurosauriaNode.add_child(eendNode)

# Perform action
theropodiaNode.perform_action()
开发者ID:Boonstra,项目名称:4.1WD-Python-Tree-Traversal,代码行数:32,代码来源:main.py


注:本文中的node.Node.add_child方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。