public static class Groups.Dendrogram extends Object
The dendrogram is created using the agglomerative strategy (i.e., a bottom-up approach) based on the following steps:
0
), each node belongs to its own cluster. At this point, each node of the original graph (the one that will
be clustered) is mapped to one of the dendrogram nodes that represent a leaf node (i.e., a node with no children).
getDissimilarityValue(Node)
. The dissimilarity values are monotone increasing starting from zero
which corresponds to the leaf nodes of the dendrogram.
Root
.
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 NodeList
s 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 NodeList
s where the first contains nodes v1, v2
and the second v3, v4
.
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
.Groups.hierarchicalClustering(Graph, INodeDistanceProvider, Linkage)
,
Groups.hierarchicalClustering(Graph, int, INodeMap, INodeDistanceProvider, Linkage)
,
Groups.hierarchicalClustering(Graph, INodeMap, INodeDistanceProvider, Linkage, double)
Modifier and Type | Method and Description |
---|---|
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
NodeList s 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()
Gets 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()
Gets 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()
Gets the root node of the dendrogram.
|
boolean |
isLeaf(Node node)
Returns whether or not the given dendrogram node is a leaf node.
|
public NodeList getChildren(Node parent)
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.
parent
- the parent node for which to retrieve the child nodespublic NodeList[] getClusterNodes(Node node)
NodeList
s 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
NodeList
s where the first contains nodes v1, v2
and the second v3, v4
.
public double getDissimilarityValue(Node node)
Node
that belongs to the dendrogram representation and not to the original graph.node
- the given dendrogram nodepublic int getLevel(Node node)
Node
that belongs to the dendrogram representation and not to the original graph.node
- the given dendrogram nodepublic int getLevelCount()
public Node getNodeAtLevel(int level)
If the given level index is greater than the number of levels
, then this method will
return null
.
IllegalArgumentException
- if the given level is negative or greater than the node count
minus one.level
- the given level indexnull
if there exists no level with the given
index.public int getNodeCount()
public Node getOriginalNode(Node node)
null
if the given node
is not a leaf node.node
- the given leaf nodenull
if the given node is an inner
dendrogram nodepublic Node getRoot()
A dendrogram traversal can be implemented by starting from this node, then moving on to its children using method
getChildren(Node)
, and so on.
public boolean isLeaf(Node 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)
.
Node
that belongs to the dendrogram representation and not to the original graph.node
- a dendrogram nodetrue
if the given node is a leaf node, false
otherwise