The distance function is implementation dependend and can only be computed between two objects of the same class (in this example the class is Item).

My goal is to write a module for a k-medoids clustering algorithm. The class MedoidClassification shall be able to partition a list of objects from the same class, which implement the Medoid interface.

My current approach is this (which does not work):

interface Medoid {
    float distance( Medoid other );
    uint id() const @property;
}

class Item : Medoid {
    float distance( Item m ) {...}
    uint id() const @property {...}
}

class MedoidClassification {
    this( Medoid[] list ) {...}
    Medoid[][] getClusters() {...}
}

void main() {
    Item[10] items;
    auto mc = MedoidClassification( items );
}


What would be a good way to implement this?

Reply via email to