- Course: Practice/Real-Life Applications of Computational Algorithms, Spring 2021 Midterm Project Milestone3 - implement one SAT application
- Author: 0710006 Ke-Yu Lu
- Date: May 24, 2021
- Reference: "Encoding Treewidth into SAT"
Decide whether the treewidth of a simple undirected graph is at most
g++ -std=c++17 -o main main.cpp
./main [input] [output] ./MiniSat_v1.14_linux
The encoded CNF has
The first line is the number of vertices
n m k
a1 b1
a2 b2
.
.
.
am bm
If the treewidth is greater than NO
. Otherwise, output YES
.
The treewidth of a tree is 1.
graph LR
0 --- 1
1 --- 2
1 --- 3
4 3 1
0 1
1 2
1 3
YES
The treewidth of a complete graph K_n is n.
graph LR
0 --- 1
1 --- 2
2 --- 0
3 3 2
0 1
1 2
2 0
YES
3 3 1
0 1
1 2
2 0
NO
graph LR
0 --- 1
0 --- 2
0 --- 3
1 --- 2
3 --- 1
2 --- 3
4 6 2
0 1
0 2
0 3
1 2
1 3
2 3
NO
4 6 3
0 1
0 2
0 3
1 2
1 3
2 3
YES