static Expression ToSAT(List <_3COL.Node> nodes) { curVariables = new List <Variable>(); AndOperator and = null; // Jeder Knoten muss mindestens eine Farbe haben foreach (var node in nodes) { OrOperator or = null; foreach (var color in colors) { if (or == null) { or = new OrOperator(Vari(node, color), null); } else if (or.Right == null) { or.Right = Vari(node, color); } else { or = new OrOperator(or, Vari(node, color)); } } if (and == null) { and = new AndOperator(or, null); } else if (and.Right == null) { and.Right = or; } else { and = new AndOperator(and, or); } } // Jeder Knoten darf maximal eine Farbe haben foreach (var node in nodes) { foreach (var c1 in colors) { foreach (var c2 in colors) { if (c1 == c2) { continue; } and = new AndOperator(and, new NotOperator( new AndOperator( Vari(node, c1), Vari(node, c2)))); } } } // Mein Nachbar darf nicht die selbe farbe haben foreach (var conn in connections) { foreach (var c in colors) { and = new AndOperator(and, new NotOperator( new AndOperator( Vari(conn.Item1, c), Vari(conn.Item2, c)))); } } string s = and.ToString(); return(and); }