Skip to content

test(dsl): add modern-graph regression tests for built-in graph algorithms - #829

Open
CalebWang0126 wants to merge 1 commit into
apache:masterfrom
CalebWang0126:issue-794-algorithm-regression-tests
Open

test(dsl): add modern-graph regression tests for built-in graph algorithms#829
CalebWang0126 wants to merge 1 commit into
apache:masterfrom
CalebWang0126:issue-794-algorithm-regression-tests

Conversation

@CalebWang0126

Copy link
Copy Markdown

Fixes #794

What & why

Several built-in algorithms were never exercised on the standard modern graph by GQLAlgorithmTest: khop, closeness_centrality and lpa were only tested on ad-hoc graphs (g4/g5), and common_neighbors / jaccard_similarity had only a single parameter case. This PR adds five end-to-end CALL ... YIELD pairs on modern_graph.sql.

Expected outputs — verified by hand

The modern graph has vertices 1..6 and directed edges 1->2, 1->3, 1->4, 4->3, 4->5, 6->3 (algorithms using EdgeDirection.BOTH treat it as undirected).

  • khop(1, 2) -> (1,0),(2,1),(3,1),(4,1),(5,2): BFS distances from vertex 1 within 2 hops; vertex 6 is unreachable. Consistent with the existing SSSP expectations on the same graph.
  • closeness_centrality(1) -> 1.0: sum of shortest distances from 1 to reachable vertices = 1+1+1+2 = 5, and n-1 = 5, so 5/5 = 1.0.
  • lpa() -> all vertices converge to label 1: simulated round by round; on ties the implementation keeps the lexicographically smallest label, which makes the outcome deterministic on this graph.
  • common_neighbors(4, 6) -> 3: N(4) = {1,3,5}, N(6) = {3}, intersection = {3}.
  • jaccard_similarity(1, 4) -> 0.2: N(1) = {2,3,4}, N(4) = {1,3,5}, intersection = {3}, union size = 5, so 1/5 = 0.2.

Test

mvn test -Dtest=GQLAlgorithmTest passes (39 tests, including the 5 new ones). Checkstyle passes.

Notes

While adding the jaccard case I noticed that for non-adjacent vertex pairs the algorithm always returns 0.0: common-neighbor confirmations are sent in iteration 2 but only reach vertex A in iteration 3, which the process() method does not handle. E.g. jaccard_similarity(4, 6) returns 0.0 although the mathematical value is 1/3. The existing (1,3) case passes only because 1 and 3 happen to be adjacent. This seems worth a separate issue; happy to file one if the maintainers agree.

Louvain / ASSP were intentionally not added: their tie-breaking depends on HashMap iteration order, which makes hand-verified expectations impractical.

…rality, lpa, common_neighbors and jaccard_similarity

Add five CALL ... YIELD .sql/.txt pairs on the standard modern graph for
algorithms with thin coverage in GQLAlgorithmTest, with all expected
outputs verified by hand (fixes apache#794).
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.

Add runnable .sql examples and regression tests for the built-in graph algorithms

1 participant