def test_connected_components(self): g = DiGraph() for i in range(1000): g6.add_node(i) g6.add_edge(i - 1, i, 1) if i % 100 != 0: g6.add_edge(i, i - 1, 1) ga6 = GraphAlgo(g6) self.assertEqual(len(ga6.connected_components()), 10) ga6.get_graph().add_edge(100, 99, 1) self.assertEqual(len(ga6.connected_components()), 9)
def test_load_save(self): algo = GraphAlgo() self.assertFalse(algo.load_from_json("../data/sadasasdas.json")) self.assertTrue(algo.load_from_json("../data/T0.json")) self.assertTrue(algo.save_to_json("../data/Test.json")) graph = algo.get_graph() self.assertEqual(graph.v_size(), 4) self.assertEqual(graph.e_size(), 5)