Пример #1
0
    def add_conflict(self, exclusive_vertices):
        """
        Add a tuple of exclusive vertices.
        """
        for u in exclusive_vertices:
            self.__check_id(u)

        conflicts = G.get_graph_property(self, "conflicts")
        conflicts.add(tuple(exclusive_vertices))
        G.set_graph_property(self, "conflicts", conflicts)

        return conflicts
Пример #2
0
    def add_sum_constraint(self, vertices_left, vertices_right):
        """
        Require that the number of selected G2 nodes centered
        around a G1 node u is equal to the left and right
        of u. Ensures that we do not get branching.
        """
        assert (type(vertices_left) == list)
        assert (type(vertices_right) == list)

        for u in vertices_left + vertices_right:
            self.__check_id(u)

        sum_constraints = G.get_graph_property(self, "sum_constraints")
        sum_constraints.append(tuple([vertices_left, vertices_right]))
        G.set_graph_property(self, "sum_constraints", sum_constraints)
Пример #3
0
 def get_sum_constraints(self):
     return G.get_graph_property(self, "sum_constraints")
Пример #4
0
 def get_conflicts(self):
     return G.get_graph_property(self, "conflicts")
Пример #5
0
 def get_must_pick_one(self):
     return G.get_graph_property(self, "must_pick_one")
Пример #6
0
 def add_must_pick_one(self, g2_vertex_list):
     must_pick_one = G.get_graph_property(self, "must_pick_one")
     must_pick_one.append(tuple(g2_vertex_list))
     G.set_graph_property(self, "must_pick_one", must_pick_one)