Example #1
0
    def test_003(self):
        g = ActionDigraph(17, 31)
        for i in range(17):
            with self.assertRaises(RuntimeError):
                g.number_of_scc()
            for j in range(31):
                g.add_edge(i, (7 * i + 23 * j) % 17, j)

        self.assertEqual(g.number_of_edges(), 31 * 17)
        self.assertEqual(g.number_of_nodes(), 17)
        with self.assertRaises(RuntimeError):
            g.add_edge(0, 0, 32)
        for i in range(17):
            for j in range(31):
                self.assertEqual(g.neighbor(i, j), (7 * i + 23 * j) % 17)

        g.add_to_out_degree(10)
        self.assertEqual(g.out_degree(), 41)
        self.assertEqual(g.number_of_nodes(), 17)
        self.assertFalse(g.validate())

        for i in range(17):
            for j in range(10):
                g.add_edge(i, (7 * i + 23 * j) % 17, 31 + j)

        self.assertEqual(g.number_of_edges(), 41 * 17)
        self.assertEqual(g.number_of_nodes(), 17)
Example #2
0
 def test_001(self):
     g = ActionDigraph(42)
     self.assertEqual(g.number_of_nodes(), 42)
     self.assertEqual(g.number_of_edges(), 0)