feat(algorithm): add Degree graph algorithm for vertex in/out degree … - #827
Open
yourshana wants to merge 1 commit into
Open
feat(algorithm): add Degree graph algorithm for vertex in/out degree …#827yourshana wants to merge 1 commit into
yourshana wants to merge 1 commit into
Conversation
…computation Closes apache#795
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(algorithm): add Degree graph algorithm for vertex in/out degree computation
Closes #795
What changes were proposed in this PR?
Add a built-in UDGA
Degreealgorithm that computes per-vertex in-degree and out-degree. Each vertex outputs(id, in_degree, out_degree)by directly counting edges vialoadEdges(EdgeDirection.IN/OUT).No iteration or message passing is needed — degree is an intrinsic vertex property that depends only on the vertex's own edge list, not on any neighbor's state. This makes it simpler than PageRank/KCore while still exercising the full
AlgorithmUserFunctioninterface (init/process/finish/getOutputType).Changes:
Degree.javaimplementingAlgorithmUserFunction<Object, Object>BuildInSqlFunctionTable.java(UDGA section)testAlgorithmDegreeinGQLAlgorithmTest.javagql_algorithm_degree.sqland expected resultgql_algorithm_degree.txtIsolated vertices (degree 0) are correctly output as
(id, 0, 0)sinceloadEdgesreturns an empty list for vertices with no edges.How was this PR tested?
Test
testAlgorithmDegreepasses using themodern_graphtest graph (6 vertices, 6 edges). Expected results were manually verified: