distanceTo

inline fun <ID : Any> Aggregate<ID>.distanceTo(source: Boolean, metric: Field<ID, Double> = hops().toDouble(), maxDiameter: Int = Int.MAX_VALUE): Double

Computes the distance from the nearest source node as a Double.

The distance between neighboring devices is computed using the metric function and defaults to the hop-count metric.

Return

The computed Double distance to the closest source.

Parameters

ID

The type used for neighbor identifiers.

source

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

metric

A Field<ID, Double> providing edge weights to each neighbor. Defaults to hops().toDouble().

maxDiameter

Maximum allowed hops before discarding paths. Defaults to Int.MAX_VALUE.


inline fun <ID : Any, Distance : Comparable<Distance>> Aggregate<ID>.distanceTo(source: Boolean, bottom: Distance, top: Distance, metric: Field<ID, Distance>, maxDiameter: Int = Int.MAX_VALUE, noinline accumulateDistance: Reducer<Distance>): Distance

Computes the distance from the nearest source node within a specified range.

Starting from bottom at a source and up to top, distances between neighboring devices are computed using the metric function and accumulated via accumulateDistance.

Return

The computed Distance to the closest source.

Parameters

ID

The type used for neighbor identifiers.

Distance

The comparable type representing path lengths.

source

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

bottom

The zero-distance value at a source.

top

The maximum allowed distance; incoming distances are clamped to this value.

metric

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

maxDiameter

Maximum allowed hops before discarding paths. Defaults to Int.MAX_VALUE.

accumulateDistance

Reducer function to combine two distances.