Skip to content

feat(algorithm): add Degree graph algorithm for vertex in/out degree … - #827

Open
yourshana wants to merge 1 commit into
apache:masterfrom
yourshana:feature/add-degree-algorithm
Open

feat(algorithm): add Degree graph algorithm for vertex in/out degree …#827
yourshana wants to merge 1 commit into
apache:masterfrom
yourshana:feature/add-degree-algorithm

Conversation

@yourshana

Copy link
Copy Markdown

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 Degree algorithm that computes per-vertex in-degree and out-degree. Each vertex outputs (id, in_degree, out_degree) by directly counting edges via loadEdges(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 AlgorithmUserFunction interface (init/process/finish/getOutputType).

Changes:

  • New Degree.java implementing AlgorithmUserFunction<Object, Object>
  • Registered in BuildInSqlFunctionTable.java (UDGA section)
  • Added test method testAlgorithmDegree in GQLAlgorithmTest.java
  • Added test SQL gql_algorithm_degree.sql and expected result gql_algorithm_degree.txt

Isolated vertices (degree 0) are correctly output as (id, 0, 0) since loadEdges returns an empty list for vertices with no edges.

How was this PR tested?

  • Tests have Added for the changes
  • Production environment verified

Test testAlgorithmDegree passes using the modern_graph test graph (6 vertices, 6 edges). Expected results were manually verified:

Vertex in_degree out_degree
1 0 3
2 1 0
3 3 0
4 1 2
5 1 0
6 0 1

@yourshana

Copy link
Copy Markdown
Author

#795

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 a simple graph algorithm: Degree

1 participant