Class WeightFunctions
- Author:
- Barak Ugav
-
Method Summary
Modifier and TypeMethodDescriptionstatic IWeightFunction
Treat a given weight function as a weight function on a graph with integer vertices.static IWeightFunction
Get a 'local' version of a given weight function.static IWeightFunctionInt
Get a 'local' version of a given weight function.static IWeightFunction
Get a weight function that returns the negative of the given weight function.
-
Method Details
-
negate
Get a weight function that returns the negative of the given weight function.- Parameters:
w
- a weight function- Returns:
- a weight function that returns the negative of the given weight function
-
localEdgeWeightFunction
Get a 'local' version of a given weight function.A
IWeightFunction
is a functional interface, and may be implemented in many mays, querying the weight of a single vertex/edge may be arbitrarily costly. In scenarios in which the weights of the vertices/edges are needed multiple times, it may be more efficient to query the weights of each vertex/edge once and store the result locally, to ensure the potentially heavy computations occur few as possible.This method accept a weight function, and return a 'local' version of it. If the original weight function is already some 'local' implementation of a weight function, it will simply be returned without duplication. In other cases, in which the implementation decide to, the weights of all the vertex/edges are computed onces and stored in a local weight function, which is than returned. In all cases, the returned weight function is local.
This function is used only for performance boost, it does not change any functionally over using the original weight function as long the original weight function or the graph are not changed.
- Parameters:
g
- a graphw
- a weight function- Returns:
- a local version of the weight function
-
localEdgeWeightFunction
Get a 'local' version of a given weight function.A
IWeightFunction
is a functional interface, and may be implemented in many mays, and querying the weight of a single edge may be arbitrarily costly. In scenarios in which the weights of the edges are needed multiple times, it may be more efficient to query the weights of each edge once and store the result locally, to ensure the potentially heavy computations occur few as possible.This method accept a weight function, and return a 'local' version of it. If the original weight function is already some 'local' implementation of a weight function, it will be returned as is without duplication. In other cases, in which the implementation decide to, the weights of the edges are computed onces and stored in a local weight function, which is than returned. In all cases, the returned weight function is local.
This function is used only for performance boost, it does not change any functionally over using the original weight function.
- Parameters:
g
- a graphw
- a weight function- Returns:
- a local version of the weight function
-
asIntGraphWeightFunc
Treat a given weight function as a weight function on a graph with integer vertices.- Parameters:
w
- a weight function- Returns:
- a weight function on a graph with integer vertices
-