apache / apache/geaflow

Add a simple graph algorithm: `Degree`

Open
#795 2 comments 0 reactions 2 assignees Claimed by @cbqiao View on GitHub
enhancement good first issue
Dominant language
Java
Stars
808
Forks
188
Avg merge
3d 22h
Merged PRs (30d)
2

Description

### What & why

The most basic graph metric is a vertex's **degree** — in-degree, out-degree,
total. It's a building block for many heavier algorithms, but there's no built-in
one-shot version yet. This is the best possible first taste of the
vertex-centric / message-passing model: simpler than PageRank, but you still walk
the full algorithm interface end to end.

图分析最基础的指标就是顶点的**度**(入度/出度/总度),它是很多复杂算法的前置特征,
但目前没有内置算法。这是入门"顶点中心 / 消息传递"模型的最佳第一题——比 PageRank 简单,
却完整走一遍算法接口。

### The task

Implement `Degree`: for each vertex, output `(id, in_degree, out_degree)`.
No message passing needed — you can count directly with `loadEdges(IN/OUT)`,
which makes it a clean way to learn the API.

实现 `Degree`:每个顶点输出 `(id, in_degree, out_degree)`。不用消息传递,直接用
`loadEdges(IN/OUT)` 统计即可,特别适合熟悉 API。

### Where to look

1. The simplest reference is `udf/graph/KCore.java`. Implement the
`AlgorithmUserFunction` interface — `init / process / finish /
getOutputType` — and in `process` count edges with
`context.loadEdges(EdgeDirection.IN/OUT)`.
2. Register in `BuildInSqlFunctionTable.java` (the UDGA section).
3. Test with `modern_graph.sql` under `query/` + `expect/`, verifying each
vertex's in/out degree by hand.

### Done when

- [ ] Implemented and registered; output schema has id / in_degree / out_degree
- [ ] Isolated vertices (degree 0) are output correctly too
- [ ] `.sql` + `.txt` tests pass, expectations checked by hand
- [ ] The PR explains why no iteration / message passing is needed

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.