Search this API

y.algo
Class Groups.Dendrogram

java.lang.Object
  extended by y.algo.Groups.Dendrogram
Enclosing class:
Groups

public static class Groups.Dendrogram
extends java.lang.Object

This class provides the result of hierarchical clustering algorithms by means of a binary tree structure.

The dendrogram is created using the agglomerative strategy (i.e., a bottom-up approach) based on the following steps:

The dendrogram is a binary tree that is directed from the root to the leaves. This means that one can iterate the dendrogram starting with the root node, moving on to its children, then moving on to their children and so on.

From each node of the dendrogram, it is possible to retrieve the set of nodes of the original graph that belong to this dendrogram node using getClusterNodes(Node). This method returns an array of NodeLists that contain the nodes of all clusters that are merged when this dendrogram node was created. For example, say that clusters C1 = {v1, v2} and C2 = {v3, v4} are merged, where {v1, v2, v3, v4} are nodes of the original graph. Say that dendrogram node u is created by this merging. Then, the cluster nodes of u will be returned as two NodeLists where the first contains nodes v1, v2 and the second v3, v4.

 
Only the leaf nodes of the dendrogram are mapped with a node of the original graph. This means that for all other inner nodes of the dendrogram, method getOriginalNode(Node) returns null.
See Also:
Groups.hierarchicalClustering(Graph, Distances, byte), Groups.hierarchicalClustering(Graph, int, NodeMap, Distances, byte), Groups.hierarchicalClustering(Graph, NodeMap, Distances, byte, double)
 

Method Summary
 NodeList getChildren(Node parent)
          Returns a NodeList that contains the child nodes of the given parent node.
 NodeList[] getClusterNodes(Node node)
          Returns an array of NodeLists that contain the nodes of the original graph that are associated with the given dendrogram node.
 double getDissimilarityValue(Node node)
          Returns the dissimilarity value associated with the given node of the dendrogram.
 int getLevel(Node node)
          Returns the level of the given node of the dendrogram.
 int getLevelCount()
          Returns the number of levels this dendrogram has.
 Node getNodeAtLevel(int level)
          Returns the node of the dendrogram that belongs to the given level index.
 int getNodeCount()
          Returns the number of nodes in this dendrogram.
 Node getOriginalNode(Node node)
          Returns the node of original graph that is mapped with the given leaf node of the dendrogram.
 Node getRoot()
          Returns the root node of the dendrogram.
 boolean isLeaf(Node node)
          Returns whether or not the given dendrogram node is a leaf node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getRoot

public Node getRoot()
Returns the root node of the dendrogram.

A dendrogram traversal can be implemented by starting from this node, then moving on to its children using method getChildren(Node), and so on.

Returns:
the root node of the dendrogram

getChildren

public NodeList getChildren(Node parent)
Returns a NodeList that contains the child nodes of the given parent node.

If the given node is a leaf node, the returned list will be empty.

Parameters:
parent - the parent node for which to retrieve the child nodes
Returns:
the list of child nodes of the given parent node

getLevel

public int getLevel(Node node)
Returns the level of the given node of the dendrogram.

 
This method expects a Node that belongs to the dendrogram representation and not to the original graph.
Parameters:
node - the given dendrogram node
Returns:
the level of the given dendrogram node

getNodeAtLevel

public Node getNodeAtLevel(int level)
Returns the node of the dendrogram that belongs to the given level index.

If the given level index is greater than the number of levels, then this method will return null.

Parameters:
level - the given level index
Returns:
the node of the dendrogram that belongs to the given level index or null if there exists no level with the given index.
Throws:
java.lang.IllegalArgumentException - if the given level is negative or greater than the node count minus one.

getOriginalNode

public Node getOriginalNode(Node node)
Returns the node of original graph that is mapped with the given leaf node of the dendrogram.

 
This method is meant to be called only for the leaf nodes of the dendrogram and returns null if the given node is not a leaf node.
Parameters:
node - the given leaf node
Returns:
the node of original graph that is mapped with the given leaf node or null if the given node is an inner dendrogram node

getDissimilarityValue

public double getDissimilarityValue(Node node)
Returns the dissimilarity value associated with the given node of the dendrogram.

 
This method expects a Node that belongs to the dendrogram representation and not to the original graph.
Parameters:
node - the given dendrogram node
Returns:
the dissimilarity value associated with the given dendrogram node

getClusterNodes

public NodeList[] getClusterNodes(Node node)
Returns an array of NodeLists that contain the nodes of the original graph that are associated with the given dendrogram node.

Each such NodeList represents nodes that belong to the same cluster. For example, say that clusters C1 = {v1, v2} and C2 = {v3, v4} are merged, where {v1, v2, v3, v4} are nodes of the original graph. Say that dendrogram node u is created by this merging. Then, the cluster nodes of u will be returned as two NodeLists where the first contains nodes v1, v2 and the second v3, v4.

 
This method expects a Node that belongs to the dendrogram representation and not to the original graph.
Parameters:
node - the given dendrogram node
Returns:
an array of NodeLists that contain the nodes of the original graph that are associated with the given dendrogram node

isLeaf

public boolean isLeaf(Node node)
Returns whether or not the given dendrogram node is a leaf node.

A leaf node has no further children and represents a node of the original graph. The original node can be retrieved via getOriginalNode(Node).

 
This method expects a Node that belongs to the dendrogram representation and not to the original graph.
Parameters:
node - a dendrogram node
Returns:
true if the given node is a leaf node, false otherwise

getNodeCount

public int getNodeCount()
Returns the number of nodes in this dendrogram.

Returns:
the number of nodes in this dendrogram

getLevelCount

public int getLevelCount()
Returns the number of levels this dendrogram has.

Returns:
the number of levels of this dendrogram

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.