Beispiel #1
0
        /**
         * Topologically sort the clusters. Note that this is a brute force sort by removing the min cluster from the list
         * of clusters, since Collections.sort() does not work in all cases.
         *
         * @param clusters the list of clusters to be topologically sorted
         * @return a topologically sorted list of clusters
         */
        private List <Cluster> topologicalSort(List <Cluster> clusters)
        {
            var            comparator = new ClusterComparator();
            List <Cluster> sorted     = new List <Cluster>(clusters.Count);

            while (!clusters.IsEmpty())
            {
                Cluster cluster = Java.Min(clusters, comparator);
                clusters.Remove(cluster);
                sorted.Add(cluster);
            }
            return(sorted);
        }