Пример #1
0
    def get_type_global(self, curr: Cut, change_time: int) -> Cut:
        final_cut = Cut()
        final_cut.set(curr.cl.copy(), curr.pl.copy())

        self.random_replace_edge(final_cut, change_time)

        return final_cut
Пример #2
0
    def expand_cut(self, initial: Cut) -> None:
        print("Expanding cut...")
        self.cut_stack.append(initial)
        self.set_hash_key(initial)

        while len(self.cut_stack) > 0:
            curr_cut = self.cut_stack.pop(-1)

            if len(curr_cut.pl) > self.biggest_cut:
                self.biggest_cut = len(curr_cut.pl)

            self.num_explored_cut += 1
            all_parents = self.one_less_edge(curr_cut.cl)

            for parent in all_parents:
                if self.support_el(parent) >= self.support_count:
                    print(parent)
                    self.MF[self.mini_idx].append(parent)
                    all_children = self.one_more_edge(parent)

                    for child in all_children:
                        if self.support_el(child) < self.support_count:
                            add_cut = Cut()
                            add_cut.set(child, parent)
                            if not self.get_hash_key(add_cut):
                                self.set_hash_key(add_cut)
                                self.cut_stack.append(add_cut)
                        else:
                            cm_child = self.find_common_child(
                                curr_cut.cl, child)
                            add_cut = Cut()
                            add_cut.set(cm_child, child)
                            if not self.get_hash_key(add_cut):
                                self.set_hash_key(add_cut)
                                self.cut_stack.append(add_cut)
                else:
                    grand_parents = self.one_less_edge(parent)
                    for gp in grand_parents:
                        if self.support_el(gp) >= self.support_count:
                            add_cut = Cut()
                            add_cut.set(parent, gp)
                            if not self.get_hash_key(add_cut):
                                self.set_hash_key(add_cut)
                                self.cut_stack.append(add_cut)

                            break