cube/
cube.rs

1/*
2=== CUBE EXAMPLE ===
3
4Run with GraphViz (https://graphviz.org/):
5
6    cargo run --example cube | dot -Tpng > test.png
7
8*/
9
10use graph_solver::*;
11
12// Notice that edges starts with `2`.
13// This is because `0` is empty and `1` is no-edge.
14const EDGE: Color = 2;
15
16fn main() {
17    let mut g = Graph::new();
18
19    // Create a node pattern with 3 edges.
20    let a = Node {
21        color: 0,
22        self_connected: false,
23        edges: vec![Constraint {edge: EDGE, node: 0}; 3]
24    };
25
26    // Add 8 vertices.
27    for _ in 0..8 {g.push(a.clone())}
28    g.no_triangles = true;
29
30    let entropy_solve_settings = EntropySolveSettings::new()
31        .attempts(1000)
32        .noise(0.5)
33        .final_attempt(Some(None));
34    let solve_settings = SolveSettings::new();
35    if let (_n, Some(solution)) = g.solve(entropy_solve_settings, solve_settings) {
36        println!("{}", solution.puzzle.graphviz(
37            "sfdp",
38            &["black"],
39            &["black"]
40        ));
41    } else {
42        eprintln!("<no solution>");
43    }
44}