Class PartitionFunctions.BalancedPartition<DATA>

  • Type Parameters:
    DATA - The type of the data objects.
    All Implemented Interfaces:
    PartitionFunction<DATA>
    Enclosing class:
    PartitionFunctions

    public static class PartitionFunctions.BalancedPartition<DATA>
    extends Object
    implements PartitionFunction<DATA>
    A partition function that tries to distribute the data objects equally between the promoted data objects, associating to each promoted data objects the nearest data objects.
    • Constructor Detail

      • BalancedPartition

        public BalancedPartition()
    • Method Detail

      • process

        public Pair<Set<DATA>> process​(Pair<DATA> promoted,
                                       Set<DATA> dataSet,
                                       DistanceFunction<? super DATA> distanceFunction)
        Processes the balanced partition.

        The algorithm is roughly equivalent to this:

             While dataSet is not Empty:
                 X := The object in dataSet which is nearest to promoted.first
                 Remove X from dataSet
                 Add X to result.first
                 
                 Y := The object in dataSet which is nearest to promoted.second
                 Remove Y from dataSet
                 Add Y to result.second
                 
             Return result
         
        Specified by:
        process in interface PartitionFunction<DATA>
        Parameters:
        promoted - The pair of data objects that will guide the partition process.
        dataSet - The original set of data objects to be partitioned.
        distanceFunction - A distance function to be used on the partitioning.
        Returns:
        A pair of partition sub-sets. Each sub-set must correspond to one of the promoted data objects.
        See Also:
        PartitionFunction.process(Pair, java.util.Set, DistanceFunction)