Beispiel #1
0
 def test_case_4(self):
     # a cyclic input fsa
     # after trimming, the cycle remains (it is not a self-loop);
     # so the output fsa is NOT topsorted.
     s = r'''
     0 3 3 1
     0 2 2 2
     1 0 1 3
     2 6 -1 4
     3 5 5 5
     3 2 2 6
     3 5 5 7
     4 4 4 8
     5 3 3 9
     5 4 4 10
     6
     '''
     fsa = k2host.str_to_fsa(s)
     connection = k2host.Connection(fsa)
     array_size = k2host.IntArray2Size()
     connection.get_sizes(array_size)
     fsa_out = k2host.Fsa.create_fsa_with_size(array_size)
     status = connection.get_output(fsa_out)
     self.assertFalse(status)
     self.assertFalse(k2host.is_top_sorted(fsa_out))
Beispiel #2
0
 def test_good_case2(self):
     s = r'''
     0 1 0 0
     0 2 0 0
     1 2 0 0
     3
     '''
     fsa = k2host.str_to_fsa(s)
     self.assertTrue(k2host.is_top_sorted(fsa))
Beispiel #3
0
 def test_bad_cases1(self):
     s = r'''
     0 1 0 0
     0 2 0 0
     2 1 0 0
     2
     '''
     fsa = k2host.str_to_fsa(s)
     self.assertFalse(k2host.is_top_sorted(fsa))
Beispiel #4
0
 def test_case_3(self):
     # a non-connected, non-topsorted, acyclic input fsa;
     # the output fsa is topsorted.
     s = r'''
     0 3 3 1
     0 5 5 2
     1 2 2 3
     2 1 1 4
     3 5 5 5
     3 2 2 -6
     3 4 4 7
     3 6 -1 8
     4 5 5 9
     4 6 -1 10
     5 6 -1 11
     6
     '''
     fsa = k2host.str_to_fsa(s)
     connection = k2host.Connection(fsa)
     array_size = k2host.IntArray2Size()
     connection.get_sizes(array_size)
     fsa_out = k2host.Fsa.create_fsa_with_size(array_size)
     connection.get_output(fsa_out)
     self.assertTrue(k2host.is_top_sorted(fsa_out))
Beispiel #5
0
 def test_good_cases1(self):
     # empty fsa
     array_size = k2host.IntArray2Size(0, 0)
     fsa = k2host.Fsa.create_fsa_with_size(array_size)
     self.assertTrue(k2host.is_top_sorted(fsa))