def test_no_simple_planar_graph(self): g = Graph(8, [[None, 1, None, None, None, None, None, None], [None, None, 1, 1, None, None, None, None], [None, 1, None, None, 1, None, None, None], [None, 1, None, None, None, 1, None, 1], [None, None, 1, None, None, 1, 1, None], [None, None, None, 1, 1, None, 1, None], [None, None, None, None, 1, 1, None, 1], [None, None, None, 1, None, None, 1, None]]) self.assertTrue(PlanarTest(g).lr_planarity())
def test_Petersen_graph(self): g = Graph(10, [[None, 1, None, None, 1, None, 1, None, None, None], [1, None, 1, None, None, None, None, 1, None, None], [None, 1, None, 1, None, None, None, None, 1, None], [None, None, 1, None, 1, None, None, None, None, 1], [1, None, None, 1, None, 1, None, None, None, None], [None, None, None, None, 1, None, 1, 1, 1, 1], [1, None, None, None, None, 1, None, 1, 1, 1], [None, 1, None, None, None, 1, 1, None, 1, 1], [None, None, 1, None, None, 1, 1, 1, None, 1], [None, None, None, 1, None, 1, 1, 1, 1, None]]) self.assertFalse(PlanarTest(g).lr_planarity())
def create_graph(node_count, matrix, weighted, ordered): if not weighted and not ordered: return UnweightedUnorderedGraph(node_count, matrix) if not weighted and ordered: return UnweightedOrderedGraph(node_count, matrix) planar = PlanarTest(Graph(node_count, matrix)).lr_planarity() if planar and not ordered: return WeightedPlanarUnorderedGraph(node_count, matrix) if planar and ordered: return WeightedPlanarOrderedGraph(node_count, matrix) if not ordered: return WeightedUnorderedGraph(node_count, matrix) if ordered: return WeightedOrderedGraph(node_count, matrix)
def test_get_adjacency_list(self): graph = Graph(3, [[None, 1, 1], [1, None, 1], [1, 1, None]]) self.assertEqual(graph.adjacency_list, [[1, 2], [0, 2], [0, 1]])
def test_edge_count(self): graph = Graph( 5, [[None, 1, 1, 1, 1], [1, None, 1, 1, 1], [1, 1, None, 1, 1], [1, 1, 1, None, 1], [1, 1, 1, 1, None]]) self.assertEqual(graph.edge_count, 10)
def test_empty_graph_with_not_empty_matrix(self): graph = Graph(0, [[None, 1, 1], [1, None, 1], [1, 1, None]]) self.assertListEqual(graph.edge_list, []) self.assertListEqual(graph.adjacency_list, []) self.assertListEqual(graph.adjacency_vertices, []) self.assertListEqual(graph.adjacency_vertices, [])
def test_get_edges(self): graph = Graph(3, [[None, 1, 1], [1, None, 1], [1, 1, None]]) self.assertEqual(graph.edge_list, [(0, 1), (0, 2), (1, 2)])
def test_get_vertices(self): graph = Graph(3, [[None, 1, 1], [1, None, 1], [1, 1, None]]) self.assertEqual(graph.get_adjacency_vertices(), [0, 1, 2])
def test_k5_graph(self): g = Graph(5, [[None, 1, 1, 1, 1], [1, None, 1, 1, 1], [1, 1, None, 1, 1], [1, 1, 1, None, 1], [1, 1, 1, 1, None]]) self.assertFalse(PlanarTest(g).lr_planarity())
def test_full_graph_more_than_5_nodes(self): g = Graph(6, [[None, 1, 1, 1, 1, 1], [1, None, 1, 1, 1, 1], [1, 1, None, 1, 1, 1], [1, 1, 1, None, 1, 1], [1, 1, 1, 1, None, 1], [1, 1, 1, 1, 1, None]]) self.assertFalse(PlanarTest(g).lr_planarity())
def test_full_graph_less_than_5_nodes(self): g = Graph(3, [[None, 1, 1], [1, None, 1], [1, 1, None]]) self.assertTrue(PlanarTest(g).lr_planarity())