Skip to content

Fix Misra-Gries edge coloring for UnGraphMap - #1707

Open
mikegit123git wants to merge 1 commit into
Qiskit:mainfrom
mikegit123git:fix-ungraphmap-misra-gries-edge-coloring
Open

mikegit123git wants to merge 1 commit into
Qiskit:mainfrom
mikegit123git:fix-ungraphmap-misra-gries-edge-coloring

Conversation

@mikegit123git

Copy link
Copy Markdown

Summary

Fixes #1593.

Fix a panic in misra_gries_edge_color() when used with Petgraph's UnGraphMap.

Undirected GraphMap adjacency iterators may return edge references with a reversed orientation relative to their canonical stored edge IDs. Direct edge index lookup can therefore panic with edge not found.

Changes

  • Build a mapping from canonical edge IDs to internal indices.
  • Add endpoint-based fallback for reversed edge references.
  • Preserve parallel-edge identity through exact edge ID lookup.
  • Detect ambiguous endpoint mappings.
  • Use unified edge indexing for color reads and updates.
  • Keep the public API unchanged.

Regression Tests

Added coverage for:

  • Original two-edge UnGraphMap reproducer.
  • Reversed edge insertion.
  • Triangle with reversed edge orientations.
  • Five-node complete graph (K5).
  • StableGraph parallel edges.
  • StableGraph sparse edge indices.

Validation

All local checks passed:

  • cargo test -p rustworkx-core: 536 tests passed.
  • cargo fmt --all -- --check: passed.
  • cargo clippy -p rustworkx-core --all-targets -- -D warnings: passed.
  • git diff --check: passed.

@CLAassistant

CLAassistant commented Nov 9, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
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.

misra_gries_edge_color panicking on UnGraphMap

2 participants