jklustor-all-api-0.0.7-20140619012755 (ChemAxon)


com.chemaxon.clustering.util
Class Util

Object
  extended by com.chemaxon.clustering.util.Util

@Beta
public final class Util
extends Object

Clustering related utility methods.

Please note that this class is marked with Beta annotation, so it can be subject of incompatible changes or removal in later releases.

Author:
Gabor Imre

Nested Class Summary
static class Util.StringScatterPlot
          ASCII scatter plot.
 
Method Summary
static int countNumberOfClusters(HierarchicClustering<?,? extends HierarchicCluster<?>> c)
          Count the number of clusters in a clustering.
static
<T> String
hierarchicIndexOf(T member, HierarchicClustering<T,? extends HierarchicCluster<T>> clustering)
          Consruct a hierarchic index for a given member of a clustering.
static String hierarchyToString(IDBasedHierarchicClustering clustering, IDBasedAssigner levels, List<String> labels, int cols)
          Render a minimalist dendrogram from a String.
static DissimilarityInput linearEuclideanDissimilarityInput(double[] values)
          Construct a DissimilarityInput over a set of 1D values.
static int maxDepth(HierarchicClustering<?,? extends HierarchicCluster<?>> c)
          Find max depth.
static String toJsonMixed(IDBasedHierarchicClustering clustering)
          Provide a JSON-like representation for Web GUI widget display.
static
<T> List<T>
traversePostOrderDFS(PostOrderDfsVisitor<T> visitor, IDBasedHierarchicClustering clustering)
          Invoke recursive DFS post order traversal on a hierarchy.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toJsonMixed

public static String toJsonMixed(IDBasedHierarchicClustering clustering)
Provide a JSON-like representation for Web GUI widget display.

Please note that the provided representation is not defined, it can be changed in future releases.

Parameters:
clustering - Clustering to JSonify
Returns:
JSON representation

countNumberOfClusters

public static int countNumberOfClusters(HierarchicClustering<?,? extends HierarchicCluster<?>> c)
Count the number of clusters in a clustering.

Parameters:
c - A clustering
Returns:
Total number of clusters, including singletons

maxDepth

public static int maxDepth(HierarchicClustering<?,? extends HierarchicCluster<?>> c)
Find max depth.

Parameters:
c - A clustering
Returns:
Max parent-children steps required to reach every leaf

hierarchicIndexOf

public static <T> String hierarchicIndexOf(T member,
                                           HierarchicClustering<T,? extends HierarchicCluster<T>> clustering)
Consruct a hierarchic index for a given member of a clustering.

Hierarchic index is a comma (,) separated list of 1-based indexes of the path leading to the given member from the roots. In a clustering, hierarchic index "2,3,4" means that the given member is acessible from the second root's third child cluster, as its fourth element. The previous elements can be further clusters or leaf nodes.

This implementation orders child clusters before immediate leaves.

Type Parameters:
T - Type of clustered members
Parameters:
member - A member
clustering - Associated clustering
Returns:
1-based, comma separated compact (no whitespaces) hierarchic index string of the given member
Throws:
IllegalArgumentException - when the given member is not part of the given clustering

linearEuclideanDissimilarityInput

public static DissimilarityInput linearEuclideanDissimilarityInput(double[] values)
Construct a DissimilarityInput over a set of 1D values.

Parameters:
values - Values to consider
Returns:
Dissimilarity input representing their euclidean distances

traversePostOrderDFS

public static <T> List<T> traversePostOrderDFS(PostOrderDfsVisitor<T> visitor,
                                               IDBasedHierarchicClustering clustering)
Invoke recursive DFS post order traversal on a hierarchy.

Type Parameters:
T - Traversal result type
Parameters:
visitor - Callback interface for traversal/skipping
clustering - Clustering to traverse
Returns:
Result list of traversal associated to roots

hierarchyToString

public static String hierarchyToString(IDBasedHierarchicClustering clustering,
                                       IDBasedAssigner levels,
                                       List<String> labels,
                                       int cols)
Render a minimalist dendrogram from a String.

Parameters:
clustering - Source clustering to use
levels - Level assignemnt to use
labels - Leaf labels for leaf IDs
cols - Total columns
Returns:
String representation of the given clustering

jklustor-all-api-0.0.7-20140619012755 (ChemAxon)