I'm working on a project where I have to read a file representing a graph. I made the input file looks like this:
b c
a c d
a b
b
So each line signifies a node. For eg, the first line is node a which is connected to b and c and the second is node b connected to a, c, and d. So I'm not really sure where to start here. I know that we need a bunch of if and else statements such that two nodes sharing an edge cannot have the same color and each node should have at least one color. But then how can I create the node variables itself as the text file can contain any amount of nodes. I know what I have to do for the bunch of if and else statements but I do not get how can I use that to reduce it to a miniSAT format like:
p cnf 3 3
1 -2 0
2 -3 0
-1 3 0
where the first "3" represents the number of variables and the second 3 represents the number of clauses. The other lines consist of different variables such that each different number is its own variable and if it's positive then it is true else false