Newer
Older
// Assigns all vertices to none
for (unsigned int i = 0; i < g->num_vertices(); i++) {
vertices_[sg_a] = 0;
vertices_[sg_b] = 0;
vertices_[none] = g->num_vertices();
}
unsigned int partition::num_vertices(subgraph sg) {
}
void partition::assign_vertex(vertex_id v, subgraph sg) {
// Returns if v is already assigned to a subgraph
// Increments current objectives
for (auto const& target : supergraph_->get_adjacency(v)) {
if (vertex_assignments_[target-1] == -sg) {
current_objective_++;
vertex_assignments_[v-1] = sg;
vertices_[sg]++;
vertices_[none]--;
}
void partition::unassign_vertex(vertex_id v) {
// Returns if v is not assigned to a subgraph
if (sg == none) {
return;
}
// Decrements current objectives
for (auto const& target : supergraph_->get_adjacency(v)) {
if (vertex_assignments_[target-1] == -sg) {
current_objective_--;
}
}
// Reverts assignment to subgraph
vertex_assignments_[v-1] = none;
vertices_[sg]--;
vertices_[none]++;