Skip to content

Conversation

@Shubham-Khetan-2005
Copy link
Contributor

Add Floyd-Warshall All-Pairs Shortest Path Algorithm in Go

Added an implementation of the Floyd-Warshall algorithm, a dynamic programming approach to find the shortest paths between all pairs of vertices in a weighted, directed graph. This algorithm is notable for its ability to handle negative edge weights and detect the presence of negative-weight cycles.

Features 🚀

Computes the shortest path distances for every pair of vertices in the graph.

Returns two matrices: a distance matrix and a next matrix, which facilitates easy reconstruction of the shortest path.

Correctly processes graphs with negative edge weights.

Provides robust negative-weight cycle detection. If a cycle is found, the algorithm indicates that the shortest paths are indeterminate.

Includes a thorough test suite that verifies correctness on graphs with positive weights, negative weights, negative cycles, and disconnected components.

Complexity Analysis 📊

Time Complexity

O(V
3
), due to its three nested loops over the set of vertices, making it suitable for dense graphs.

Space Complexity

O(V
2
) to store the distance and next matrices for all pairs of vertices.

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

🎉 Welcome to Hacktoberfest 2025, @Shubham-Khetan-2005! 🎃

Thank you for your first contribution to our DSA repository! Here's what happens next:

🔍 Automatic Checks

  • Code Validation: Passed
  • 🧪 Compilation Tests: Passed

📋 Next Steps

🎯 Great job! Your code compiled successfully. Maintainers @Karanjot786 and @Pradeepsingh61 will review your PR soon.

🎁 What You Get

  • 🏆 Hacktoberfest Credit: This PR counts toward your 6 PR goal for exclusive T-shirt + Tree!
  • 🌟 Hall of Fame: You'll be featured in our contributors list
  • 📚 Learning: Code review feedback from experienced developers

💡 Tips for Success

  • Follow our Contributing Guidelines
  • Add comments explaining your algorithm
  • Include time/space complexity analysis
  • Test your code before submitting

Welcome to the community! 🚀

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

🤖 Automated PR Status

🔍 Code Validation

Passed - File naming and structure look good!

🧪 Compilation Tests

Passed - All code compiles successfully!

📋 Overall Status

🎉 Ready for Review - Your PR has passed all automated checks!
👥 Maintainers have been notified for review.


This comment was generated automatically. Checks will re-run when you push new commits.

@github-actions github-actions bot requested a review from Karanjot786 October 8, 2025 17:46
@Pradeepsingh61 Pradeepsingh61 merged commit 0a73519 into Pradeepsingh61:main Oct 10, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants