multiGradientCast

inline fun <ID : Any, Value, Distance : Comparable<Distance>> Aggregate<ID>.multiGradientCast(sources: Iterable<ID>, local: Value, bottom: Distance, top: Distance, metric: Field<ID, Distance>, maxDiameter: Int = Int.MAX_VALUE, noinline accumulateData: (fromSource: Distance, toNeighbor: Distance, data: Value) -> Value = { _, _, data -> data }, crossinline accumulateDistance: Reducer<Distance>): Map<ID, Value>

Computes, for each ID in sources, a fast-repair gradient propagation of local values, returning a map from each source ID to its propagated value at this device.

For each source in sources, this function invokes gradientCast with that ID as the sole source. If no valid path exists from a given source, the local value is used as a fallback.

Return

A Map<ID, Value> mapping each source ID to the propagated data value at this device.

Parameters

ID

The type used for neighbor identifiers.

Value

The type of data being propagated.

Distance

The comparable type representing distances.

sources

The collection of device IDs to treat as sources.

local

The local data value or default if a source is unreachable.

bottom

The zero-distance value at a source. Must be ≤ top.

top

The maximum distance threshold; incoming distances are clamped into [bottom, top].

metric

A Field<ID, Distance> providing edge weights to each neighbor.

maxDiameter

Maximum allowed number of hops; paths longer than this are discarded. Defaults to Int.MAX_VALUE.

accumulateData

Function to combine 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.

accumulateDistance

Reducer to accumulate two Distance values; used for path-length accumulation.

See also


inline fun <ID : Any, Value> Aggregate<ID>.multiGradientCast(sources: Iterable<ID>, local: Value, metric: Field<ID, Double>, maxDiameter: Int = Int.MAX_VALUE, noinline accumulateData: (fromSource: Double, toNeighbor: Double, data: Value) -> Value = { _, _, data -> data }): Map<ID, Value>

Computes a fast-repair gradient propagation from multiple sources, returning a map of the propagated values for each source ID.

For each ID in sources, this function invokes gradientCast treating only that ID as the source node. It uses metric to compute edge distances, applies accumulateData at each hop, and accumulates distances by plain addition (Double::plus). If a source is unreachable or there are no neighbors, it falls back to local.

Return

A Map<ID, Value> mapping each source ID to its propagated value at this device.

Parameters

ID

The type used for device identifiers.

Value

The type of data being propagated.

sources

The collection of device IDs to use as sources.

local

The local data value or default if a source path is not found.

metric

A Field<ID, Double> providing edge weights to each neighbor.

maxDiameter

Maximum allowed hops before discarding a path. Defaults to Int.MAX_VALUE.

accumulateData

Function to update data on each hop. Receives the neighbor’s distance from the source, the edge distance to this device, and the neighbor’s data. Defaults to the identity function.

See also