tom's blog

By tom, history, 9 years ago, In English

Hello,

I'm solving problem with 2-SAT algorithm and I need to be sure that some xi will be 1 (or 0). How can I make this happen with 2SAT algorithm? When I add "xi or xi", I put xi and not xi into one SCC and 2-SAT returns me that there is no solution. Is it possible?

Thanks

  • Vote: I like it
  • +13
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it +18 Vote: I do not like it

when you add x or x you shouldn't put them in one SCC. because you are adding 2 same sdges.

»
9 years ago, # |
  Vote: I like it +18 Vote: I do not like it

If you want to force x_i to be true just add implication !x_i -> x_i.

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

It's simple: BFS over the 2-SAT graph (the skew-symmetric one) from the fixed variables while checking for contradictions. When it finishes, there will be no edge from a known variable to an unknown one. The skew-symmetricity makes sure that there's no unfixed variable from which a fixed variable can be reached afterwards, so any solution of the unfixed part of the graph + the variables you fixed this way is a solution of the original problem.