8000 Added property checks for lollipop graph by Krishn1412 · Pull Request #1453 · Qiskit/rustworkx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added property checks for lollipop graph #1453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 29, 2025
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
78 changes: 78 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rustworkx-core/Cargo.toml
1044A
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ rand_distr.workspace = true
rand_pcg.workspace = true
rayon.workspace = true
rayon-cond = "0.4"

[dev-dependencies]
quickcheck = "1.0"
quickcheck_macros = "1.0"
1 change: 1 addition & 0 deletions rustworkx-core/tests/quickcheck/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod special_graph;
44 changes: 44 additions & 0 deletions rustworkx-core/tests/quickcheck/special_graph.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use petgraph::graph::UnGraph;
use quickcheck::{quickcheck, TestResult};
use rustworkx_core::generators::lollipop_graph;

#[test]
fn prop_lollipop_graph_structure() {
fn prop(mesh_size: usize, path_size: usize) -> TestResult {
// Constrain input space for sanity
let mesh_size = mesh_size % 64;
let path_size = path_size % 64;

if mesh_size + path_size == 0 {
return TestResult::discard();
}
if mesh_size <= 1 {
return TestResult::discard();
}

let graph = match lollipop_graph::<UnGraph<(), ()>, (), _, _, ()>(
Some(mesh_size),
Some(path_size),
None,
None,
|| (),
|| (),
) {
Ok(g) => g,
Err(_) => return TestResult::error("Unexpected error in graph generation"),
};

let expected_nodes = mesh_size + path_size;
let mesh_edges = mesh_size * (mesh_size - 1) / 2;
let path_edges = path_size.saturating_sub(1);
let connector = if path_size > 0 { 1 } else { 0 };
let expected_edges = mesh_edges + path_edges + connector;

let node_match = graph.node_count() == expected_nodes;
let edge_match = graph.edge_count() == expected_edges;

TestResult::from_bool(node_match && edge_match)
}

quickcheck(prop as fn(usize, usize) -> TestResult);
}
0