Esempio n. 1
0
 def __is_valid_graph(self, edges: Iterable[Tuple[int, int]]) -> str:
     """Test graph and return True if it is valid."""
     try:
         g = Graph(edges)
     except (TypeError, ValueError):
         return "wrong format"
     if not g.edges:
         return "is an empty graph"
     if not g.is_connected():
         return "is not a close chain"
     if not is_planar(g):
         return "is not a planar chain"
     if g.has_cut_link():
         return "has cut link"
     try:
         external_loop_layout(g, True)
     except ValueError as error:
         return str(error)
     for h in self.collections:
         if g.is_isomorphic(h):
             return f"is isomorphic with: {h.edges}"
     return ""
Esempio n. 2
0
 def test_graph_basic(self):
     """Test 'graph' libraries."""
     g1 = Graph([(0, 1), (0, 4), (1, 5), (2, 3), (2, 4), (3, 5), (4, 5)])
     self.assertFalse(g1.is_degenerate())
     self.assertTrue(g1.is_connected())
     self.assertEqual(1, g1.dof())