001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.math3.stat.clustering;
019
020import java.io.Serializable;
021import java.util.ArrayList;
022import java.util.List;
023
024/**
025 * Cluster holding a set of {@link Clusterable} points.
026 * @param <T> the type of points that can be clustered
027 * @since 2.0
028 * @deprecated As of 3.2 (to be removed in 4.0),
029 * use {@link org.apache.commons.math3.ml.clustering.Cluster} instead
030 */
031@Deprecated
032public class Cluster<T extends Clusterable<T>> implements Serializable {
033
034    /** Serializable version identifier. */
035    private static final long serialVersionUID = -3442297081515880464L;
036
037    /** The points contained in this cluster. */
038    private final List<T> points;
039
040    /** Center of the cluster. */
041    private final T center;
042
043    /**
044     * Build a cluster centered at a specified point.
045     * @param center the point which is to be the center of this cluster
046     */
047    public Cluster(final T center) {
048        this.center = center;
049        points = new ArrayList<T>();
050    }
051
052    /**
053     * Add a point to this cluster.
054     * @param point point to add
055     */
056    public void addPoint(final T point) {
057        points.add(point);
058    }
059
060    /**
061     * Get the points contained in the cluster.
062     * @return points contained in the cluster
063     */
064    public List<T> getPoints() {
065        return points;
066    }
067
068    /**
069     * Get the point chosen to be the center of this cluster.
070     * @return chosen cluster center
071     */
072    public T getCenter() {
073        return center;
074    }
075
076}