Skip to content

CodingThrust/problem-reductions

Repository files navigation

Problem Reductions

CI codecov Documentation License: MIT

A Rust library for NP-hard problem definitions and reductions.

Features

  • 18+ Problem Types: Implementations of classic NP-hard problems
  • Type-Safe Reductions: Compile-time verified problem transformations
  • Graph Abstraction: Generic Graph trait with SimpleGraph and UnitDiskGraph implementations
  • Multiple Solvers: BruteForce and ILP (HiGHS) solvers
  • Topology Types: HyperGraph and UnitDiskGraph for specialized constraints
  • File I/O: JSON serialization for all problem types

Installation

Add to your Cargo.toml:

[dependencies]
problemreductions = "0.1"

Quick Start

use problemreductions::prelude::*;

// Create an Independent Set problem
let problem: IndependentSetT = IndependentSetT::new(4, vec![(0, 1), (1, 2), (2, 3)]);

// Solve with brute force
let solver = BruteForce::new();
let solutions = solver.find_best(&problem);

// Apply a reduction
let result = ReduceTo::<VertexCoverT>::reduce_to(&problem);
let vc = result.target_problem();

Problem Types

Category Problems
Satisfiability SAT, K-SAT, CircuitSAT, Factoring
Graph IndependentSet, MaximalIS, VertexCovering, DominatingSet, Coloring, MaxCut, Matching
Set SetCovering, SetPacking
Optimization SpinGlass, QUBO
Specialized Paintshop, BicliqueCover, BMF

Available Reductions

  • IndependentSet ↔ VertexCovering
  • IndependentSet ↔ SetPacking
  • SpinGlass ↔ QUBO
  • SpinGlass ↔ MaxCut

Documentation

Development

Using Make

make help      # Show all available targets
make build     # Build the project
make test      # Run all tests
make fmt       # Format code with rustfmt
make fmt-check # Check code formatting
make clippy    # Run clippy lints
make doc       # Build and open documentation
make coverage  # Generate coverage report (requires cargo-llvm-cov)
make clean     # Clean build artifacts
make check     # Quick check before commit (fmt + clippy + test)

Using Cargo directly

cargo build --all-features
cargo test --all-features
cargo doc --all-features --no-deps --open

License

MIT License - see LICENSE for details.

About

A Rust library for NP-hard problem definitions and reductions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •