Skip to content

Refactor Lazy and Eager Prim's MST implementations#1311

Merged
williamfiset merged 2 commits into
masterfrom
refactor-prims-mst
Apr 1, 2026
Merged

Refactor Lazy and Eager Prim's MST implementations#1311
williamfiset merged 2 commits into
masterfrom
refactor-prims-mst

Conversation

@williamfiset
Copy link
Copy Markdown
Owner

@williamfiset williamfiset commented Apr 1, 2026

Summary

  • Add Javadoc explaining lazy vs eager approaches, time/space complexity
  • Use Integer.compare() instead of subtraction in compareTo() to avoid overflow
  • Apply single-line body formatting rule throughout
  • Trim the indexed priority queue in EagerPrims to only the operations needed by the algorithm (removed size, pollMinKeyIndex, valueOf, update, increase, toString, isMinHeap, and validation helpers)
  • Consolidate duplicated print logic into printMst helper, fix "No MST does not exists" typo
  • Clean up examples: rename for clarity, remove benchmark and duplicate slide examples
  • Add JUnit 5 tests for both LazyPrims (13 tests) and EagerPrims (14 tests), including a lazy-vs-eager agreement test

Test plan

  • bazel test //src/test/java/com/williamfiset/algorithms/graphtheory:LazyPrimsAdjacencyListTest — 13 tests pass
  • bazel test //src/test/java/com/williamfiset/algorithms/graphtheory:EagerPrimsAdjacencyListTest — 14 tests pass

🤖 Generated with Claude Code

williamfiset and others added 2 commits March 31, 2026 18:25
…s, trim IPQ

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@williamfiset williamfiset merged commit a0857a6 into master Apr 1, 2026
2 checks passed
@williamfiset williamfiset deleted the refactor-prims-mst branch April 1, 2026 01:36
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.

1 participant