PageRank Graph Statistics in HugeGraph Computer#
HugeGraph Computer's PageRank implementation normalizes rank values using the total vertex count of the graph, which is propagated to every worker at the start of each superstep via the SuperstepStat object. Understanding this flow is essential for debugging convergence issues or extending the algorithm.
How totalVertexCount Reaches the Algorithm#
The count travels through three layers:
1. Collection β SuperstepStat
SuperstepStat is a serializable object that accumulates counters across all workers. Its vertexCount field is built by summing partition-level stats and worker-level stats via increase(). At the end of the input step and each compute step, the master calls SuperstepStat.from(workerStats) to produce the global aggregate. SuperstepStat is serializable via read/write so it can be transmitted over the wire .
2. Distribution β Master β Workers
After each superstep, MasterService calls bsp4Master.masterStepDone(superstep, superstepStat) to broadcast the SuperstepStat to all workers. Workers block on bsp4Worker.waitMasterStepDone(superstep), which returns the SuperstepStat for the next superstep's context.
3. Exposure β WorkerContext / MasterComputationContext
The SuperstepStat is wrapped in a SuperstepContext on both sides:
- Worker side (
WorkerService.SuperstepContext):totalVertexCount()delegates directly tosuperstepStat.vertexCount(). - Master side (
MasterService.SuperstepContext):totalVertexCount()also reads fromsuperstepStat.vertexCount().
These context objects implement WorkerContext and MasterComputationContext respectively, which declare totalVertexCount() as part of their API.
Workers collect PartitionStat
β
βΌ
WorkerStat (per worker) β BSP barrier β MasterService
β
SuperstepStat.from(workerStats)
β
bsp4Master.masterStepDone(stat)
β
Workers: waitMasterStepDone()
β
SuperstepContext wraps stat
β
WorkerContext.totalVertexCount()
How PageRank Uses totalVertexCount#
In PageRank.beforeSuperstep(), the worker calls context.totalVertexCount() to read the globally aggregated vertex count, then uses it for three normalization purposes :
| Variable | Formula | Purpose |
|---|---|---|
initialValue | 1.0 / totalVertex | Initial rank per vertex in superstep 0 |
danglingRank | danglingTotalRank / totalVertex | Dangling-node rank redistribution per vertex |
initialRankInSuperstep | alpha / totalVertex | Teleportation factor contribution per vertex |
During compute(), the per-vertex rank update is :
rank = (danglingRank + rankFromNeighbors) * (1 - alpha) + initialRankInSuperstep
rank /= cumulativeRank β re-normalization against previous superstep's total
Aggregator Pipeline (Worker β Master)#
PageRank uses four global aggregators registered by PageRank4Master.init():
| Aggregator Key | Type | Combiner | Role |
|---|---|---|---|
pagerank.aggr_l1_norm_difference | DOUBLE | DoubleValueSumCombiner | Convergence check |
pagerank.comulative_probability | DOUBLE | DoubleValueSumCombiner | Total rank mass |
pagerank.dangling_vertices_num | LONG | LongValueSumCombiner | Count of sinks |
pagerank.comulative_dangling_probability | DOUBLE | DoubleValueSumCombiner | Rank held at sinks |
Each worker accumulates local values via Aggregator objects created in beforeSuperstep and flushes them in afterSuperstep via context.aggregateValue(...) . The master reads the globally combined values in PageRank4Master.compute() and decides whether to continue: it returns false (halt) when superstep > 1 and the L1-norm difference falls at or below the threshold (default 0.00001) .
Key Files#
| File | Role |
|---|---|
PageRank.java | Worker computation β uses totalVertexCount for normalization |
PageRank4Master.java | Master computation β registers aggregators, checks L1 convergence |
SuperstepStat.java | Carries vertex/edge/message counts between master and workers |
MasterService.java | Orchestrates superstep loop; builds and broadcasts SuperstepStat |
WorkerService.java | Receives SuperstepStat; exposes it via WorkerContext |
WorkerContext | API giving computation access to totalVertexCount() on workers |
MasterComputationContext | API giving master computation access to graph-wide stats |