square2/square2.rs
1use graph_solver::*;
2
3// Notice that edges starts with `2`.
4const SOLID: Color = 2;
5
6fn main() {
7 let mut g = Graph::new();
8
9 // Create a node pattern.
10 let a = Node {
11 color: 0,
12 self_connected: false,
13 edges: vec![Constraint {edge: SOLID, node: 0}; 2]
14 };
15
16 // Add 4 nodes.
17 for _ in 0..4 {g.push(a.clone())}
18
19 let solve_settings = SolveSettings::new()
20 .debug(true).sleep_ms(2000);
21 if let Some(solution) = g.solve(solve_settings) {
22 // Prints:
23 // 0 0 0 0
24 // ========================================
25 // 0 2 1 0
26 // 2 0 0 1
27 // 1 0 0 2
28 // 0 1 2 0
29 solution.puzzle.print();
30 }
31}