Skip to content

Possible division by zero in PageRank when graph contains zero vertices #358

Description

@KHARSHAVARDHAN-eng

Bug Type (问题类型)

others (please edit later)

Before submit

Environment (环境信息)

Repository: apache/hugegraph-computer
Branch: master

Issue identified during source code review.
I have not yet verified it by executing the algorithm.

Expected & Actual behavior (期望与实际表现)

Expected Behavior

The PageRank implementation should safely handle graphs with zero vertices or explicitly validate this case before performing any division.

Observation

While reviewing the source code, I noticed a calculation that appears to divide by the total vertex count without an obvious check for a zero value.

If totalVertexCount can become zero, this could potentially result in a division-by-zero exception.

I have not yet been able to verify whether this execution path is reachable at runtime. I would appreciate confirmation from the maintainers on whether this scenario is possible or whether there is upstream validation that guarantees the value is always greater than zero.

If this is considered a valid issue, I would be happy to work on a fix and submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions