gov.sandia.cognition.learning.algorithm.clustering.hierarchy.AbstractClusterHierarchyNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cognitive-foundry Show documentation
Show all versions of cognitive-foundry Show documentation
A single jar with all the Cognitive Foundry components.
/*
* File: AbstractClusterHierarchyNode.java
* Authors: Justin Basilico
* Company: Sandia National Laboratories
* Project: Cognitive Foundry
*
* Copyright October 02, 2008, Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the U.S. Government. Export
* of this program may require a license from the United States Government.
* See CopyrightHistory.txt for complete details.
*
*/
package gov.sandia.cognition.learning.algorithm.clustering.hierarchy;
import gov.sandia.cognition.collection.CollectionUtil;
import gov.sandia.cognition.learning.algorithm.clustering.cluster.Cluster;
import gov.sandia.cognition.util.AbstractCloneableSerializable;
import java.util.Collection;
/**
* An abstract implementation of the {@code ClusterHierarchyNode} class. It
* keeps track of the cluster.
*
* @param
* The type of the data in the cluster.
* @param
* The type of cluster contained in the hierarchy node.
* @author Justin Basilico
* @since 2.1
*/
public abstract class AbstractClusterHierarchyNode>
extends AbstractCloneableSerializable
implements ClusterHierarchyNode
{
/** The cluster associated with the node. */
protected ClusterType cluster;
/**
* Creates a new {@code AbstractClusterHierarchyNode}.
*/
public AbstractClusterHierarchyNode()
{
this(null);
}
/**
* Creates a new {@code AbstractClusterHierarchyNode}.
*
* @param cluster
* The cluster associated with the node.
*/
public AbstractClusterHierarchyNode(
final ClusterType cluster)
{
super();
this.setCluster(cluster);
}
public boolean hasChildren()
{
return !CollectionUtil.isEmpty(this.getChildren());
}
public Collection getMembers()
{
return this.cluster.getMembers();
}
public ClusterType getCluster()
{
return cluster;
}
/**
* Sets the cluster associated with the node.
*
* @param cluster
* The cluster associated with the node.
*/
public void setCluster(
final ClusterType cluster)
{
this.cluster = cluster;
}
}