コード例 #1
0
def test_addNode():
    tree = Tree.Tree()

    tree.addNode(Node.Node('a'))
    tree.addNode(Node.Node('b'))

    with pytest.raises(RuntimeError):
        tree.addNode(Node.Node('a'))
コード例 #2
0
ファイル: tree_search.py プロジェクト: pegl/examples
def make_graph(node_count = 10):

    letters = "".join(getAllTheLetters())

    def _get_label():
        return choice(letters).upper() + choice(letters)

    def _get_random_node(tree):
        keys = range(len(tree))
        random_key = choice(keys)
        return tree.get_node_by_index(random_key).identifier

    #print choice(letters)
    tree= Tree()
    label = _get_label()
    root_node = tree.create_node(label, label.lower())
    for i in range(node_count):
        label = _get_label()
        child_node = tree.create_node(label, label.lower(), parent=_get_random_node(tree))
    return tree, root_node
コード例 #3
0
 def __init__(self, sourceIndex, parent, T, costs, vertices):
     Tree.__init__(self, sourceIndex, parent, T, vertices)
     self.costs = costs
コード例 #4
0
 def __init__(self, startingIndex, parent, T, 
              totalWeight, vertices):
     Tree.__init__(self, startingIndex, parent, T, vertices)
     # Total weight of all edges in the tree
     self.totalWeight = totalWeight 
コード例 #5
0
 def __init__(self, sourceIndex, parent, T, costs, vertices):
     Tree.__init__(self, sourceIndex, parent, T, vertices)
     self.costs = costs
コード例 #6
0
 def __init__(self, startingIndex, parent, T, totalWeight, vertices):
     Tree.__init__(self, startingIndex, parent, T, vertices)
     # Total weight of all edges in the tree
     self.totalWeight = totalWeight