|
|
@ -11,6 +11,7 @@ class HHCSim( |
|
|
|
customers: Either[String, IndexedSeq[Customer]] |
|
|
|
): String Either Map[Int, IndexedSeq[(Int, Double)]] = |
|
|
|
customers |
|
|
|
.flatMap(checkEmpty) |
|
|
|
.map(Util.formAdjMatrix) |
|
|
|
.map(edges => Util.mstUsingPrims(edges)) |
|
|
|
.map(mst => Util.findCentroids(mst)) |
|
|
@ -28,4 +29,13 @@ class HHCSim( |
|
|
|
Util.groupClusters(centroids, clusters, removed) |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
def checkEmpty( |
|
|
|
customers: IndexedSeq[Customer] |
|
|
|
): Either[String, IndexedSeq[Customer]] = |
|
|
|
customers.length match { |
|
|
|
case 0 => Left("Error input was empty") |
|
|
|
case _ => Right(customers) |
|
|
|
} |
|
|
|
|
|
|
|
} |