Skip to content
This repository was archived by the owner on Jun 18, 2026. It is now read-only.

test: add comprehensive tests for ShortestPathFinder - #91

Merged
sauravbhattacharya001 merged 1 commit into
masterfrom
test/shortest-path-finder
Mar 28, 2026
Merged

sauravbhattacharya001 merged 1 commit into
masterfrom
test/shortest-path-finder

Conversation

@sauravbhattacharya001

Copy link
Copy Markdown
Owner

Summary

Adds 20 unit tests for \ShortestPathFinder, covering BFS shortest path, Dijkstra weighted shortest path, reachability, connectivity, directed graph support, and input validation.

Test coverage includes:

  • BFS (findShortestByHops): same vertex, direct neighbor, fewest hops vs lowest weight, disconnected vertices, linear chain, null/missing vertex validation
  • Dijkstra (findShortestByWeight): same vertex, lighter path preference, zero-weight normalization to 1.0, disconnected, negative weight rejection
  • Reachability: isolated vertex returns self, connected component excludes isolated nodes
  • Connectivity: same vertex, direct neighbors, transitive, disconnected
  • PathResult.toString: format validation
  • Directed graphs: edge direction respected, reverse path returns null
  • Diamond graph: Dijkstra finds weight-optimal path through lower-cost route

Follows existing test conventions (JUNG UndirectedSparseGraph/DirectedSparseGraph, JUnit 4).

Add 20 test cases covering:
- BFS shortest path by hops (same vertex, direct neighbor, chain, disconnected)
- Dijkstra shortest path by weight (lighter path preference, zero-weight normalization, negative weight rejection)
- Reachability (isolated vertex, connected component)
- Connectivity checks (same vertex, neighbors, transitive, disconnected)
- PathResult.toString formatting
- Directed graph edge direction respect
- Diamond graph optimal path selection
- Input validation (null graph, null vertex, missing vertex)
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sauravbhattacharya001
sauravbhattacharya001 merged commit 3c9f9c3 into master Mar 28, 2026
4 of 8 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant