One framework, many problems
Maximum Planar Subgraph, Connected Dominating Set, Independent Set, Prize Collecting Vertex Cover, Facility Location, Steiner Tree — monotone and non-monotone alike. Same interface, six realizations.
General purposeAn alpha-stage Python framework for heuristic subgraph extraction. Define reward, penalty, and feasibility once; DeltaSearch handles candidate moves, rollback, and search budgets.
Turn a graph objective into a small, testable problem contract. DeltaSearch owns the search loop while your code defines domain rules, feasibility, and what a good move means.
Maximum Planar Subgraph, Connected Dominating Set, Independent Set, Prize Collecting Vertex Cover, Facility Location, Steiner Tree — monotone and non-monotone alike. Same interface, six realizations.
General purposeCandidate scoring stays local instead of recomputing the objective from scratch. Reversible actions make the search loop inspectable.
Incremental · reversibleTyped interfaces, explicit budgets, observers, thread-safe graph access, and a standard-library core make experiments easier to reproduce.
Typed · Observable · AlphaA tiny protocol, a greedy core, and pluggable solvers. Define your own problem in a handful of methods, or reach for a built-in one.
evaluate_initial_state builds a starting subgraph.
enumerate_actions lists candidate add/remove moves.
calculate_delta scores a candidate from local context.
apply_action or undo_action, always reversible.
Stop on budget, stall, or objective target.
3V − 6 = 180 edges.
That is a useful bound for simple planar graphs, not a proof of planarity.
3V − 6 Euler bound reached
·
representative view · GreedySolver
Each problem is a fleshed-out SubgraphExtractionProblem —
instantiate it on a Graph, hand it to a solver, done.
Keep as many edges as possible while screening candidates against an Euler-bound feasibility rule.
The smallest connected vertex set that dominates the whole graph.
The heaviest set of mutually non-adjacent vertices.
Balance vertex cost against uncovered-edge penalties, collecting prizes.
Where to open facilities to serve demand at the lowest total cost.
Connect a set of terminals through optional nodes at minimum edge cost.
Each move is scored from local context via calculate_delta, not a full graph re-evaluation.
Every mutation is logged in an undo stack. Backtracking restores prior state without re-scoring.
ThreadSafeGraph protects mutations and explicit snapshots with an RLock; hold the lock when coordinating live views.
The observer protocol exposes every action, delta, and objective — logging, metrics, and tracing for free.
The greedy core is the floor, not the ceiling. Every strategy shares the same problem interface, so you can upgrade the search without rewriting the problem.
MultiStartSolver
Many random starts; the best result wins.
BeamSearchSolver
Top-κ candidate states explored in parallel.
AnytimeSolver
Best-so-far progress under a time budget.
AdaptiveBeamSolver
Diversity-aware beam ordering for better coverage.
LearnedGuidanceSolver
Online ML steers action choice as it explores.
MultiObjectiveSolver
Pareto-optimal frontiers across competing objectives.
StreamingSolver
Keep solving as the graph mutates under you.
HybridPipeline
Two-stage retrieval + reasoning, end to end.
Define a problem, point a solver at it, and read the result. Optional observers, early-stopping, and NetworkX interop when you need them.
from delta_search import Graph, GreedySolver, PrizeCollectingVertexCoverProblem
# Build an input graph with O(1) adjacency lookups.
graph = Graph[int].from_edges(
[(1, 2), (2, 3), (3, 1), (3, 4),
(4, 5), (5, 2), (1, 5)]
)
# Solve: cover every edge, keep the prize, pay vertex cost.
problem = PrizeCollectingVertexCoverProblem(graph, default_penalty=2.0)
result = GreedySolver(problem).solve(max_iterations=200)
print(result.best_objective) # 95.0 — objective found
print(result.iteration) # steps taken to get there
# Solve a graph and write the solution to JSON.
$ delta-search solve --problem mps --graph input.json --output result.json
# Validate a graph before you solve it.
$ delta-search validate --graph input.json
# Available problems: mps, mcds, mwis, pcvc, uflp, mwst
developer docs.
Alpha setup: git clone the repo, then use pip install -e . locally.
An alpha-stage toolkit for six NP-hard problems, local deltas, and a search you can inspect as it converges.
Alpha release · PyPI package coming soon · Python 3.10+ · MIT