Skip to main content
. 2017 Dec 13;17(12):2902. doi: 10.3390/s17122902
Algorithm 2 K-medoids algorithm.
  • 1:

    Initialization of the centers (CH)

  • 2:

    Associate each node with its closest CH

  • 3:

    Compute the configuration cost (sum of the distances of each CM to its CH)

  • 4:

    while the configuration’s cost decreases do

  • 5:

        for each cluster do

  • 6:

            Swap the CH function with a CM node

  • 7:

            Recompute the new cost

  • 8:

            if the cost increases then

  • 9:

               Undo the swap (keep the previous configuration)

  • 10:

            end if

  • 11:

        end for

  • 12:

    end while