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'))
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
def __init__(self, sourceIndex, parent, T, costs, vertices): Tree.__init__(self, sourceIndex, parent, T, vertices) self.costs = costs
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