// LLP driver for the least mincut satisfying a lattice-linear side // predicate. The hooks Bcheck, forbiddenForB, and nextMincut are // problem-specific; the driver here is illustrative only. #include #include bool Bcheck(const std::vector& /*C*/) { return true; } bool forbiddenForB(int /*j*/, const std::vector& /*C*/) { return false; } std::vector nextMincut(const std::vector& C) { return C; } std::vector llpMincut(std::vector C) { int n = (int)C.size(); bool done = false; while (!done) { bool changed = true; while (changed) { changed = false; for (int j = 0; j < n; ++j) { if (forbiddenForB(j, C)) { if (C[j]) return {}; C[j] = true; changed = true; } } } if (Bcheck(C)) { done = true; } else { auto next = nextMincut(C); if (next.empty()) return {}; C = next; } } return C; } int main() { std::vector C(4, false); auto out = llpMincut(C); std::cout << "C:"; for (bool b : out) std::cout << ' ' << (b ? 1 : 0); std::cout << '\n'; return 0; }