Assign names to each cluster (which doesn't have a name yet)
165988
private void updateNames() {
    for(Cluster<?> cluster : clustering.getAllClusters()) {
      if(names.get(cluster) != null) {
        continue;
      }
      String sugname = cluster.getNameAutomatic();
      int count = namefreq.addTo(sugname, 1);
      names.put(cluster, sugname + " " + count);
    }
  }
1187801
protected void updateClusters() {
		for( int i = 0; i < clusters.size; i++ ) {
			clusters.data[i].reset();
		}

		int indexPixel = 0;
		for( int y = 0; y < input.height&& !stopRequested; y++ ) {
			int indexInput = input.startIndex + y*input.stride;
			for( int x =0; x < input.width; x++ , indexPixel++ , indexInput++) {
				Pixel p = pixels.get(indexPixel);

				// convert the distance each cluster is from the pixel into weights
				p.computeWeights();

				for( int i = 0; i < p.clusters.size; i++ ) {
					ClusterDistance d = p.clusters.data[i];
					d.cluster.x += x*d.distance;
					d.cluster.y += y*d.distance;
					d.cluster.totalWeight += d.distance;
					addColor(d.cluster.color,indexInput,d.distance);
				}
			}
		}

		// recompute the center of each cluster
		for( int i = 0; i < clusters.size; i++ ) {
			clusters.data[i].update();
		}
	}
1343327
function cluster(points) {
    // number of clusters has to be smaller or equal the number of data points
    if (points.length < k) {
      throw 'Too many clusters';
    }

    // create the initial clusters
    var clusters = chooseInitialCenters(points);

    // create an array containing the latest assignment of a point to a cluster
    // no need to initialize the array, as it will be filled with the first assignment
    var assignments = new Int32Array(points.length);
    assignPointsToClusters(clusters, points, assignments);
    // iterate through updating the centers until we're done
    var max = (maxIterations < 0) ? Number.MAX_VALUE : maxIterations;
    for (var count = 0; count < max; count++) {
      var emptyCluster = false;
      var newClusters = [];
      for (var clusterIndex = 0; clusterIndex < clusters.length; clusterIndex++) {
        var cluster = clusters[clusterIndex];
        var newCenter;
        if (cluster.getPoints().length === 0) {
          newCenter = getPointFromLargestVarianceCluster(clusters);
          emptyCluster = true;
        } else {
          newCenter = centroidOf(cluster.getPoints(), cluster.getCenter().getPoint().size());
        }
        newClusters.push(new CentroidCluster(newCenter));
      }
      var changes = assignPointsToClusters(newClusters, points, assignments);
      clusters = newClusters;

      // if there were no more changes in the point-to-cluster assignment
      // and there are no empty clusters left, return the current clusters
      if (changes === 0 && !emptyCluster) {
        return clusters;
      }
    }
    return clusters;
  }
476655
private void addPairs() {
		GvmCluster<S,K> cj = clusters[count];
		int c = count - 1; //index at which new pairs registered for existing clusters
		for (int i = 0; i < count; i++) {
			GvmCluster<S,K> ci = clusters[i];
			GvmClusterPair<S,K> pair = new GvmClusterPair<S,K>(ci, cj);
			ci.pairs[c] = pair;
			cj.pairs[i] = pair;
			pairs.add(pair);
		}
		
	}
449022
def list_clusters(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_clusters function must be called with -f or --function.'
        )

    server, user, password = _get_xml_rpc()
    auth = ':'.join([user, password])
    cluster_pool = server.one.clusterpool.info(auth)[1]

    clusters = {}
    for cluster in _get_xml(cluster_pool):
        clusters[cluster.find('NAME').text] = _xml_to_dict(cluster)

    return clusters
939754
def _on_cluster_discovery(self, future):
        
        LOGGER.debug('_on_cluster_discovery(%r)', future)
        common.maybe_raise_exception(future)
        nodes = future.result()
        for node in nodes:
            name = '{}:{}'.format(node.ip, node.port)
            if name in self._cluster:
                LOGGER.debug('Updating cluster connection info for %s:%s',
                             node.ip, node.port)
                self._cluster[name].set_slots(node.slots)
                self._cluster[name].set_read_only('slave' in node.flags)
            else:
                self._create_cluster_connection(node)
        self._discovery = True
935857
def describe_cluster_name(self, ):
    
    self._seqid += 1
    d = self._reqs[self._seqid] = defer.Deferred()
    self.send_describe_cluster_name()
    return d
277025
def get_cluster_name(self):
        
        return self._get(
            url=self.url + '/api/cluster-name',
            headers=self.headers,
            auth=self.auth
        )
274671
def name_parts(self):
        """"""

        default = PartialMixin.ANY

        return ([(k, default, True)
                for k, _, _ in PartitionName._name_parts]
                +
                [(k, default, True)
                 for k, _, _ in Name._generated_names]
                )
893138
protected void initClusters() {
        log.info("Generating initial clusters");
        List<Point> points = new ArrayList<>(initialPoints);

        //Initialize the ClusterSet with a single cluster center (based on position of one of the points chosen randomly)
        val random = Nd4j.getRandom();
        Distance distanceFn = clusteringStrategy.getDistanceFunction();
        int initialClusterCount = clusteringStrategy.getInitialClusterCount();
        clusterSet = new ClusterSet(distanceFn,
                        clusteringStrategy.inverseDistanceCalculation(), new long[]{initialClusterCount, points.get(0).getArray().length()});
        clusterSet.addNewClusterWithCenter(points.remove(random.nextInt(points.size())));


        //dxs: distances between
        // each point and nearest cluster to that point
        INDArray dxs = Nd4j.create(points.size());
        dxs.addi(clusteringStrategy.inverseDistanceCalculation() ? -Double.MAX_VALUE : Double.MAX_VALUE);

        //Generate the initial cluster centers, by randomly selecting a point between 0 and max distance
        //Thus, we are more likely to select (as a new cluster center) a point that is far from an existing cluster
        while (clusterSet.getClusterCount() < initialClusterCount && !points.isEmpty()) {
            dxs = ClusterUtils.computeSquareDistancesFromNearestCluster(clusterSet, points, dxs, exec);
            double r = random.nextFloat() * dxs.maxNumber().doubleValue();
            for (int i = 0; i < dxs.length(); i++) {
                double distance = dxs.getDouble(i);
                Preconditions.checkState(distance >= 0, "Encountered negative distance: distance function is not valid? Distance " +
                        "function must return values >= 0, got distance %s for function s", distance, distanceFn);
                if (dxs.getDouble(i) >= r) {
                    clusterSet.addNewClusterWithCenter(points.remove(i));
                    dxs = Nd4j.create(ArrayUtils.remove(dxs.data().asDouble(), i));
                    break;
                }
            }
        }

        ClusterSetInfo initialClusterSetInfo = ClusterUtils.computeClusterSetInfo(clusterSet);
        iterationHistory.getIterationsInfos().put(currentIteration,
                        new IterationInfo(currentIteration, initialClusterSetInfo));
    }
1208641
def _convert_to_clusters(c):
    """"""
    new_dict = {}
    n_cluster = 0
    logger.debug("_convert_to_cluster: loci %s" % c.loci2seq.keys())
    for idl in c.loci2seq:
        n_cluster += 1
        new_c = cluster(n_cluster)
        #new_c.id_prev = c.id
        new_c.loci2seq[idl] = c.loci2seq[idl]
        new_dict[n_cluster] = new_c
    logger.debug("_convert_to_cluster: new ids %s" % new_dict.keys())
    return new_dict
412917
public void setClusters(java.util.Collection<String> clusters) {
        if (clusters == null) {
            this.clusters = null;
            return;
        }

        this.clusters = new java.util.ArrayList<String>(clusters);
    }
1049366
def set_default_names(data):
    """"""
    if all(name is not None for name in data.index.names):
        return data

    data = data.copy()
    if data.index.nlevels > 1:
        names = [name if name is not None else 'level_{}'.format(i)
                 for i, name in enumerate(data.index.names)]
        data.index.names = names
    else:
        data.index.name = data.index.name or 'index'
    return data
577435
def add_to_cluster(self, name, **attrs):
        
        cluster = self.get_cluster(name=name)
        attrs_ = cluster['cluster']
        attrs_.update(**attrs)
1276178
def globNames
      names = []
      cluster = @cluster
      mf = StringIO.new(@bs.getCluster(cluster))
      loop do
        (@bs.bytesPerCluster / DIR_ENT_SIZE - 1).times do
          de = DirectoryEntry.new(mf.read)
          break if de.name == ''
          names << de.name.downcase if de.name !=
                                       DirectoryEntry::AF_DELETED && de.name[0] != DirectoryEntry::AF_DELETED
          mf = StringIO.new(de.unused)
          break if mf.size == 0
        end
        data = @bs.getNextCluster(cluster)
        break if data.nil?
        cluster = data[0]
        mf = StringIO.new(data[1])
      end
      names.sort!
    end
1052317
def monmap(cluster, hostname):
    
    monmap
    mon_map_file = '%s.%s.monmap' % (cluster, hostname)
    return join(constants.tmp_path, mon_map_file)
787269
private ArrayList<String> getNameInCluster(Cluster cluster) {
    ArrayList<String> itemsInCluster = new ArrayList<String>();

    String nodeName;
    if (cluster.isLeaf()) {
      nodeName = cluster.getName();
      itemsInCluster.add(nodeName);
    }
    else {
      // String[] clusterName = cluster.getName().split("#");
      // nodeName = clusterName[1];
    }

    for (Cluster child : cluster.getChildren()) {
      ArrayList<String> childrenNames = getNameInCluster(child);
      itemsInCluster.addAll(childrenNames);
    }
    return itemsInCluster;
  }