Generalized weight-aggregation functions instead of only +
#79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Made some simple changes to use a function
waf
, short forweight-aggregation function
. Defaults to+
, as the affected graph functions previously implicitly used.Affected functions include
dijkstra-traverse
,dijkstra-span
,bellman-ford-transform
, andjohnson
.The reason for this commit is that weights won't always be simply added: they might be multiplied, subtracted, or divided. Suppose one were to perform unit conversion, for instance, where to get from one unit to another one would multiply by a constant (or equivalently, divides by the inverse of the constant). To aggregate the conversions needed from seconds to nanoseconds using
all-pairs-shortest-paths
, one would need to not add 1/1000 to get to milliseconds, then another 1/1000 to get to microseconds, then another to get to nanoseconds, but rather to multiply them, resulting in a conversion factor of 1/1,000,000,000. There are certainly examples when weight-aggregation functions might be more complex than simply*
or+
, but I will not touch on them here.