Java icon indicating copy to clipboard operation
Java copied to clipboard

feat(graph): Add Bellman-Ford algorithm with negative cycle detection

Open vardhan30016 opened this issue 2 weeks ago • 1 comments

This PR implements the Bellman-Ford algorithm for finding shortest paths in weighted directed graphs.

Key Features: ✅ Handles negative weight edges (unlike Dijkstra) ✅ Detects negative weight cycles ✅ Comprehensive JavaDoc documentation ✅ Clean API with Result class ✅ Path reconstruction support ✅ Input validation ✅ Early termination optimization

Time Complexity: O(V × E) Space Complexity: O(V)

This implementation fills a gap in the graph algorithms collection and complements existing shortest path implementations.

  • [ ] I have read CONTRIBUTING.md.
  • [ ] This pull request is all my own work -- I have not plagiarized it.
  • [ ] All filenames are in PascalCase.
  • [ ] All functions and variable names follow Java naming conventions.
  • [ ] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • [ ] All new code is formatted with clang-format -i --style=file path/to/your/file.java

vardhan30016 avatar Nov 26 '25 05:11 vardhan30016