diff --git a/rustworkx-core/tests/quickcheck/dorogovtsev_goltsev_mendes_graph.rs b/rustworkx-core/tests/quickcheck/dorogovtsev_goltsev_mendes_graph.rs new file mode 100644 index 0000000000..4801d0295d --- /dev/null +++ b/rustworkx-core/tests/quickcheck/dorogovtsev_goltsev_mendes_graph.rs @@ -0,0 +1,25 @@ +use petgraph::graph::Graph; +use quickcheck::{quickcheck, TestResult}; +use rustworkx_core::generators::dorogovtsev_goltsev_mendes_graph; + +#[test] +fn prop_dgm_graph_structure() { + fn prop(n: u8) -> TestResult { + let n = (n % 7) as usize; + let g: Graph<(), ()> = match dorogovtsev_goltsev_mendes_graph(n, || (), || ()) { + Ok(graph) => graph, + Err(_) => return TestResult::error("Failed to generate DGM graph"), + }; + + let expected_edges = 3_usize.pow(n as u32); + let expected_nodes = (expected_edges + 3) / 2; + + if g.node_count() != expected_nodes || g.edge_count() != expected_edges { + return TestResult::failed(); + } + + TestResult::passed() + } + + quickcheck(prop as fn(u8) -> TestResult); +} diff --git a/rustworkx-core/tests/quickcheck/main.rs b/rustworkx-core/tests/quickcheck/main.rs index 072907a576..7c6b0c40da 100644 --- a/rustworkx-core/tests/quickcheck/main.rs +++ b/rustworkx-core/tests/quickcheck/main.rs @@ -2,6 +2,7 @@ mod barbell_graph; mod binomial_tree_graph; mod complete_graph; mod cycle_graph; +mod dorogovtsev_goltsev_mendes_graph; mod full_rary_tree_graph; mod grid_graph; mod heavy_hex_graph;