def test_empty_sequence(self): """Tests that joining the empty sequence results in the tree with one node. """ T = nx.join([]) assert_equal(len(T), 1) assert_equal(T.number_of_edges(), 0)
def test_empty_sequence(self): """Tests that joining the empty sequence results in the tree with one node. """ T = nx.join([]) assert len(T) == 1 assert T.number_of_edges() == 0
def test_empty_sequence(self): """Tests that joining the empty sequence #1lab_results in the tree with one node. """ T = nx.join([]) assert_equal(len(T), 1) assert_equal(T.number_of_edges(), 0)
def create_cayley_tree(z, depth, path=None): subtrees = [(nx.balanced_tree(z, depth - 1), 0) for _ in range(z + 1)] graph = nx.join(subtrees) if path is not None: nx.write_gpickle(graph, \ f'{path}/cayley_tree_z={z}_depth={depth}.gpickle', 2) return graph
def test_single(self): """Tests that joining just one tree yields a tree with one more node. """ T = nx.empty_graph(1) actual = nx.join([(T, 0)]) expected = nx.path_graph(2) assert_nodes_equal(list(expected), list(actual)) assert_edges_equal(list(expected.edges()), list(actual.edges()))
def test_single(self): """Tests that joining just one tree yields a tree with one more node. """ T = nx.empty_graph(1) actual = nx.join([(T, 0)]) expected = nx.path_graph(2) assert_equal(list(expected), list(actual)) assert_equal(list(expected.edges()), list(actual.edges()))
def joinByU(rt): '''Definition 2.1. Construct a new RootedTree obtained from two copies of rt[v] by connecting each root v to a new root u. Inherits the right label. ''' nx.set_node_attributes(rt.tree, rt.labels, 'label') joined = nx.join([(rt.tree, rt.root), (rt.tree, rt.root)]) newLabels = nx.get_node_attributes(joined, 'label') newLabels[0] = None newRT = RootedTree(joined, 0, newLabels) return newRT
def test_basic(self): """Tests for joining multiple subtrees at a root node.""" trees = [(nx.full_rary_tree(2, 2**2 - 1), 0) for i in range(2)] actual = nx.join(trees) expected = nx.full_rary_tree(2, 2**3 - 1) assert nx.is_isomorphic(actual, expected)
def test_basic(self): """Tests for joining multiple subtrees at a root node.""" trees = [(nx.full_rary_tree(2, 2 ** 2 - 1), 0) for i in range(2)] actual = nx.join(trees) expected = nx.full_rary_tree(2, 2 ** 3 - 1) assert_true(nx.is_isomorphic(actual, expected))