Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/2-sat
2SAT solver
https://github.com/mikolalysenko/2-sat
Last synced: about 2 months ago
JSON representation
2SAT solver
- Host: GitHub
- URL: https://github.com/mikolalysenko/2-sat
- Owner: mikolalysenko
- License: mit
- Created: 2013-11-01T05:41:53.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-05-15T18:02:16.000Z (over 10 years ago)
- Last Synced: 2024-10-19T00:19:15.308Z (2 months ago)
- Language: JavaScript
- Size: 145 KB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
2-sat
=====
[2SAT](http://en.wikipedia.org/wiki/2-satisfiability) is a restricted version of the boolean satisfiability problem where the number of variables per clause is at most 2. Works both in node.js and in the browser using browserify.## Example
```javascript
var twoSat = require("2-sat")//Solve problem:
//
// (x1 | !x2) & (x3 | x1) & (x3 | x2)
//
console.log(twoSat(3, [[1, -2], [3, 1], [3,2]]))
```## API
### `require("2-sat")(numVariables, clauses)`
Finds a satisfying assignment for a 2SAT problem written in conjunctive normal form. If no assignment is possible returns `false`.* `numVariables` is the number of variables
* `clauses` is a list of binary clauses. Variables are indexed in clauses starting at `1` and negative values indicate negation.**Returns** A vector of assignments to the variables of the clause. If problem is not satisfiable, returns `false`
## Credits
(c) 2013 Mikola Lysenko. MIT License