예제 #1
0
 def test_random_lcp_array(self):
   T, n, A = 100, 500, ['a', 'b']
   for _ in range(T):
     t = rand.random_word(n, A)
     reference = suffix_array.lcp_from_suffix_array(
         suffix_array.prefix_doubling(t, n), t, n)
     self.check_lcp_array(t, n, reference)
예제 #2
0
 def test_all_lcp_array(self):
   N, A = 12, ['a', 'b']
   for n in range(2, N + 1):
     for t in itertools.product(A, repeat = n):
       t = '#' + ''.join(t)
       reference = suffix_array.lcp_from_suffix_array(
           suffix_array.prefix_doubling(t, n), t, n)
       self.check_lcp_array(t, n, reference)
예제 #3
0
 def check_lcp_array(self, t, n, reference):
     self.assertEqual(
         suffix_array.lcp_from_suffix_array(
             suffix_array.prefix_doubling(t, n), t, n), reference,
         'LCP array from suffix array')
     self.assertEqual(
         suffix_array.lcp_from_suffix_tree(suffix_tree.mccreight(t, n)[0]),
         reference, 'LCP array from suffix tree')
     self.assertEqual(
         suffix_array.lcp_kasai(suffix_array.prefix_doubling(t, n), t, n),
         reference, 'Algorithm: kasai')