Skip to content

test: add comprehensive tests for ShortestPathFinder#91

Open
sauravbhattacharya001 wants to merge 1 commit intomasterfrom
test/shortest-path-finder
Open

test: add comprehensive tests for ShortestPathFinder#91
sauravbhattacharya001 wants to merge 1 commit intomasterfrom
test/shortest-path-finder

Conversation

@sauravbhattacharya001
Copy link
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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant