int Gradient Cast
Broadcasts a fast-repair integer gradient of local values from all source nodes, always retaining the data from the nearest source.
This overload applies when distances are Int, using a default range of [0, Int.MAX_VALUE] and the standard non-overflowing addition reducer.
At each device:
If
sourceistrue, propagates its ownlocalvalue with distance0.Otherwise, collects neighbor paths, accumulates distances via
accumulateDistance, appliesaccumulateDatato the neighbor’s data, and selects the path with minimal total distance.If no source path exists, returns
local.
Return
The data associated with the nearest source node along a minimal-distance, loop-free path, or local if no source is reachable.
This algorithm employs fast repair and is not subject to the rising value problem. It requires larger messages and more computation than bellmanFordGradientCast. To improve performance, provide an upper bound on the network diameter via maxDiameter.
Parameters
The type used for neighbor identifiers.
The type of data being propagated.
true if this device is a source node; otherwise false.
The local data value or fallback if no source is reachable.
A Field<ID, Int> providing edge weights to each neighbor.
Maximum allowed number of hops; paths longer than this are discarded. Defaults to Int.MAX_VALUE.
Function to update neighbor data on each hop: receives the neighbor’s distance from source, the edge distance, and the neighbor’s data. Defaults to the identity function.
Reducer to combine two distances; defaults to Int::nonOverflowingPlus.