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 solve_settings = SolveSettings::new();
31    if let Some(solution) = g.solve(solve_settings) {
32        println!("{}", solution.puzzle.graphviz(
33            "sfdp",
34            &["black"],
35            &["black"]
36        ));
37    } else {
38        eprintln!("<no solution>");
39    }
40}