hopGradientCast

inline fun <ID : Any, Type> Aggregate<ID>.hopGradientCast(source: Boolean, local: Type, maxDiameter: Int = Int.MAX_VALUE, noinline accumulateData: (fromSource: Int, toNeighbor: Int, data: Type) -> Type = { _, _, data -> data }): Type

Broadcasts a fast-repair gradient of local values using hop count as the distance metric.

Propagates values from every device where source is true, retaining the data from the nearest source (fewest hops). Internally delegates to intGradientCast with hops() as the metric and Int::plus as the distance reducer.

Return

The data associated with the nearest source node along a minimal-hop, loop-free path, or local if no source is reachable.

Parameters

ID

The type representing neighbor identifiers.

Type

The type of data being propagated.

source

True if this device is a source node; false otherwise.

local

The local data value or fallback if no source is reachable.

maxDiameter

Upper bound on path hop count; paths longer than this are discarded. Defaults to Int.MAX_VALUE.

accumulateData

Function to update neighbor data on each hop. Receives the neighbor’s distance from source (hop count), the hop increment (always 1), and the neighbor’s data. Defaults to the identity function.

See also