org.geworkbench.bison.model.clusters
Class AbstractCluster

java.lang.Object
  extended by org.geworkbench.bison.model.clusters.AbstractCluster
All Implemented Interfaces:
java.io.Serializable, Cluster
Direct Known Subclasses:
DefaultHierCluster, DefaultSOMCluster

public abstract class AbstractCluster
extends java.lang.Object
implements Cluster, java.io.Serializable

Copyright: Copyright (c) 2003

Company: First Genetic Trust Inc.

Default implementation of the Cluster interface.

Version:
$Id: AbstractCluster.java 7427 2011-02-08 22:28:38Z zji $
Author:
First Genetic Trust
See Also:
Serialized Form

Field Summary
protected  java.util.ArrayList<Cluster> children
          Holds all children of this Cluster
protected  Cluster parent
          Reference to Cluster which contains this Cluster as a child
 
Constructor Summary
AbstractCluster()
           
 
Method Summary
 void addNode(Cluster newCluster)
          Adds a Cluster node as a child of this Cluster
 Cluster[] getChildrenNodes()
          Gets all the children Cluster nodes of this node
 java.util.List<Cluster> getLeafChildren()
          Gets all the children of this Cluster that are also leaves
 int getLeafChildrenCount()
          Gets the number of children of this Cluster that are also leaves
 java.util.Map<Cluster,java.lang.Integer> getLeafChildrenCountMap()
          Returns a map of cluster to number of leaf children for that cluster.
 int getNodesCount()
          Gets the number of children of this Cluster
 Cluster getParent()
          Gets the Cluster which contains this Cluster as a child.
 boolean isLeaf()
          Specifes if this Cluster is a leaf.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

children

protected java.util.ArrayList<Cluster> children
Holds all children of this Cluster


parent

protected Cluster parent
Reference to Cluster which contains this Cluster as a child

Constructor Detail

AbstractCluster

public AbstractCluster()
Method Detail

getParent

public Cluster getParent()
Gets the Cluster which contains this Cluster as a child. Returns null is this node is the root.

Specified by:
getParent in interface Cluster
Returns:
parent

addNode

public void addNode(Cluster newCluster)
Adds a Cluster node as a child of this Cluster

Specified by:
addNode in interface Cluster
Parameters:
newCluster - added as child

isLeaf

public boolean isLeaf()
Specifes if this Cluster is a leaf. i.e. this Cluster does not contain any children

Specified by:
isLeaf in interface Cluster
Returns:
if this node is a leaf

getChildrenNodes

public Cluster[] getChildrenNodes()
Gets all the children Cluster nodes of this node

Specified by:
getChildrenNodes in interface Cluster
Returns:
children nodes as an array

getNodesCount

public int getNodesCount()
Gets the number of children of this Cluster

Specified by:
getNodesCount in interface Cluster
Returns:
number of children

getLeafChildren

public java.util.List<Cluster> getLeafChildren()
Gets all the children of this Cluster that are also leaves

Specified by:
getLeafChildren in interface Cluster
Returns:
all the leaf children as an array

getLeafChildrenCount

public int getLeafChildrenCount()
Gets the number of children of this Cluster that are also leaves

Specified by:
getLeafChildrenCount in interface Cluster
Returns:
number of leaf children

getLeafChildrenCountMap

public java.util.Map<Cluster,java.lang.Integer> getLeafChildrenCountMap()
Description copied from interface: Cluster
Returns a map of cluster to number of leaf children for that cluster. Can be used to efficiently build a dendrogram or other representation without multiple tree traversals.

Specified by:
getLeafChildrenCountMap in interface Cluster
Returns:
A map of Cluster to Integer representing the number of leaf children for that cluster.