Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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);
}
1 change: 1 addition & 0 deletions rustworkx-core/tests/quickcheck/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down