                                 ; Otherwise select the members with the minimum total distance to the others
                                 :else (apply min-key (partial total-distance members) members)))
         recluster (fn [clusters]
-                    (log/info clusters)
                     (let [initial-clusters (into {} (map (comp #(vector % #{}) find-new-medoid)
                                                          clusters))]
                       (reduce assign-to-cluster

  [^PersistentHashSet paths
   distance-fn'
   ^Number k]
  (let [distance-fn (fn [a b] (if (= a b) 0 (distance-fn' a b)))
        vj (fn [path]
             (mapsum (fn [i]
                       (/ (distance-fn path i)

        initial-clusters (into {}
                               (map (comp #(vector % #{}) first)
                                    (take k (sort-by second (map (juxt identity vj) paths)))))
        ; Path is assigned to the medoid it is closest to. 
        assign-to-cluster (fn [clusters path]
                            (update clusters
                                    (reduce (partial min-key (partial distance-fn path)) (keys clusters))
                                    conj
                                    path))
        ; Compute the total sum of distances of medoids to the members of their clusters.
        sum-distances (fn [clusters]
                        (mapsum (fn [[medoid members]]
                                  (mapsum (partial distance-fn medoid) members))
                                clusters))
        ; Compute the total of distances between the members of a cluster. 
        total-distance (fn [cluster member]
                         (mapsum (partial distance-fn member) cluster))
        ; Find new medoid from members of a cluster.
        find-new-medoid (fn [[medoid members]]
                          (cond ; If the cluster is empty, return its medoid.
                                (empty? members) medoid
