def test_number_weakly_connected_big(self): G = retworkx.PyDAG() for i in range(100000): node = G.add_node(i) G.add_child(node, str(i), {}) self.assertEqual(retworkx.number_weakly_connected_components(G), 100000)
def test_number_weakly_connected(self): G = retworkx.PyDAG() node_a = G.add_node(1) G.add_child(node_a, 2, {}) G.add_node(3) self.assertEqual(retworkx.number_weakly_connected_components(G), 2)
def test_number_weakly_connected_node_holes(self): graph = retworkx.PyDiGraph() graph.add_nodes_from([0, 1, 2]) graph.remove_node(1) self.assertEqual(retworkx.number_weakly_connected_components(graph), 2)
def test_number_weakly_connected_all_strong(self): G = retworkx.PyDAG() node_a = G.add_node(1) node_b = G.add_child(node_a, 2, {}) G.add_child(node_b, 3, {}) self.assertEqual(retworkx.number_weakly_connected_components(G), 1)
def time_number_weakly_connected_components(self): retworkx.number_weakly_connected_components(self.graph)