Beispiel #1
0
 def __find_child(self, mum):
     # find all  children under a mum
     assert isinstance(mum, Tree)
     for item in mum.node:
         if item[0]:
             l = mum.row[item[1]]
         else:
             l = mum.col[item[1]]
         m = Roll(item[2], item[3], l)
         # print(item)
         # print(l)
         m.move()
         if item[0]:
             table = mum.row.copy()
             table[item[1]] = m.result
             # print(table)
             table_t = self.__transpose(table, self.n_col)
             # print(table_t)
             node_t = snap(table, table_t)
         else:
             table = mum.col.copy()
             table[item[1]] = m.result
             # print(table)
             table_t = self.__transpose(table, self.n_row)
             node_t = snap(table_t, table)
         if len(node_t) != 0:
             self.n += 1
             if item[0]:
                 child = Tree(node_t, self.n, table, table_t, item)
             else:
                 child = Tree(node_t, self.n, table_t, table, item)
             mum.add_child(child)
Beispiel #2
0
 def __find_child(self, mum, pointy_mum):
     # find all  children under a mum
     assert isinstance(mum, Tree)
     for item in mum.node:
         if item[0]:
             l = mum.row[item[1]]
         else:
             l = mum.col[item[1]]
         m = Roll(item[2], item[3], l)
         # print(item)
         # print(l)
         m.move()
         if item[0]:
             table = mum.row.copy()
             table[item[1]] = m.result
             # print(table)
             table_t = self.__transpose(table, self.n_col)
             # print(table_t)
             node_t = snap(table, table_t)
         else:
             table = mum.col.copy()
             table[item[1]] = m.result
             # print(table)
             table_t = self.__transpose(table, self.n_row)
             node_t = snap(table_t, table)
         if len(node_t) != 0:
             self.n += 1
             if item[0]:
                 child = Tree(node_t, self.n, table, table_t, item)
             else:
                 child = Tree(node_t, self.n, table_t, table, item)
             n_row = 0
             n_col = 0
             for i in mum.row.keys():
                 if len(mum.row[i]) > 0:  # not empty
                     n_row += 1
             for i in mum.col.keys():
                 if len(mum.col[i]) > 0:
                     n_col += 1
             if n_row == 1 or n_col == 1:
                 # solution found
                 solution = True
             else:
                 solution = False
             pointy_child = PointyTree(self.n,
                                       pointy_mum.mum,
                                       solution,
                                       children=None)
             pointy_child.add_point(child)
             mum.add_child(child)
             pointy_mum.add_child(pointy_child)