Skip to content

Add Backman partial-orientation utilities and rank heuristics#35

Open
Copilot wants to merge 2 commits into
mainfrom
copilot/partial-orientations-optimizations
Open

Add Backman partial-orientation utilities and rank heuristics#35
Copilot wants to merge 2 commits into
mainfrom
copilot/partial-orientations-optimizations

Conversation

Copilot AI commented Apr 21, 2026

Copy link
Copy Markdown

Implements primitives and rank-search shortcuts motivated by Spencer Backman's Riemann–Roch theory for graph orientations (arXiv:1401.3309).

CFOrientation — partial-orientation API

  • is_partial(), oriented_edge_count(), unoriented_edge_count()
  • sources() / sinks() — vertices with indeg_O = 0 / outdeg_O = 0
  • is_acyclic() — iterative three-color DFS over the directed sub-orientation; unoriented edges are ignored, matching Backman's definition for partial orientations
  • partial_divisor() — Backman's D_O(v) = indeg_O(v) − 1; matches divisor() on full orientations but does not require fullness

CFRank — new optimized=True shortcuts

  • Negative-degree: deg(D) < 0 ⇒ rank = −1, skipping the EWD call
  • Riemann–Roch lower bound: when deg(D) − g ≥ 1, start the search at k = deg(D) − g + 1 since r(D) ≥ deg(D) − g guarantees D − E is winnable for all smaller k. Gated so the pre-existing K − D swap heuristic is exercised only when this bound is not useful (no behavior change on that path).
from chipfiring import CFOrientation, rank

# Acyclicity check on a partial orientation (ignores unoriented edges)
o = CFOrientation(graph, [("v1", "v2"), ("v2", "v3")])
o.is_acyclic()           # True
o.partial_divisor()      # D_O(v) = indeg_O(v) - 1, no fullness required

# Optimized rank skips EWD for deg < 0 and shrinks the k-search via R-R
rank(divisor, optimized=True).rank

Tests

11 new tests in tests/test_cforientation.py and tests/test_cfrank.py covering each new method and both new optimizations.

Copilot AI changed the title [WIP] Add partial orientations and rank related optimizations Add Backman partial-orientation utilities and rank heuristics Apr 21, 2026
Copilot AI requested a review from DhyeyMavani2003 April 21, 2026 03:39
@DhyeyMavani2003 DhyeyMavani2003 marked this pull request as ready for review April 21, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Partial Orientations and Rank Related Optimizations [Spencer Backman] for Heuristics

2 participants