Class WeightFunctions

    • Method Detail

      • negate

        public static IWeightFunction negate​(IWeightFunction w)
        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

        public static IWeightFunction localEdgeWeightFunction​(IndexGraph g,
                                                              IWeightFunction w)
        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 graph
        w - a weight function
        Returns:
        a local version of the weight function
      • localEdgeWeightFunction

        public static IWeightFunctionInt localEdgeWeightFunction​(IndexGraph g,
                                                                 IWeightFunctionInt w)
        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 graph
        w - a weight function
        Returns:
        a local version of the weight function
      • asIntGraphWeightFunc

        public static IWeightFunction asIntGraphWeightFunc​(WeightFunction<Integer> w)
        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