Exemple #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
Exemple #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)
Exemple #3
0
    def __init__(self, N):
        G.__init__(self, N)

        # Initialized with 0.0, see graph.G and tests
        G.new_vertex_property(self, "costs", dtype="double")

        G.new_graph_property(self, "conflicts", dtype="python::object")
        G.set_graph_property(self, "conflicts", set())

        G.new_graph_property(self, "sum_constraints", dtype="python::object")
        G.set_graph_property(self, "sum_constraints", list())

        G.new_vertex_property(self, "forced", dtype="bool", value=False)
        G.new_vertex_property(self, "solved", dtype="bool", value=False)

        G.new_graph_property(self, "must_pick_one", dtype="python::object")
        G.set_graph_property(self, "must_pick_one", list())
Exemple #4
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)