@Beta @PublicAPI public final class Util extends Object
Please note that this class is marked with Beta
annotation, so it can be subject of incompatible changes
or removal in later releases.
Modifier and Type | Class and Description |
---|---|
static class |
Util.StringScatterPlot
ASCII scatter plot.
|
Modifier and Type | Method and Description |
---|---|
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 String |
toMultilineString(IDBasedHierarchicClustering clustering,
String prefix) |
static <T> List<T> |
traversePostOrderDFS(PostOrderDfsVisitor<T> visitor,
IDBasedHierarchicClustering clustering)
Invoke recursive DFS post order traversal on a hierarchy.
|
static void |
traverseSimpleDfs(IDBasedHierarchicClustering h,
SimpleDfsVisitor preorderVisitorOrNull,
SimpleDfsVisitor postorderVisitorOrNull)
Simple DFS traversal.
|
static void |
traverseSimplePostOrderDfs(IDBasedHierarchicClustering h,
SimpleDfsVisitor postOrderVisitor)
Simple postorder DFS traversal.
|
static void |
traverseSimplePreOrderDfs(IDBasedHierarchicClustering h,
SimpleDfsVisitor preOrderVisitor)
Simple preorder DFS traversal.
|
public static String toMultilineString(IDBasedHierarchicClustering clustering, String prefix)
public static String toJsonMixed(IDBasedHierarchicClustering clustering)
Please note that the provided representation is not defined, it can be changed in future releases.
clustering
- Clustering to JSonifypublic static int countNumberOfClusters(HierarchicClustering<?,? extends HierarchicCluster<?>> c)
c
- A clusteringpublic static int maxDepth(HierarchicClustering<?,? extends HierarchicCluster<?>> c)
c
- A clusteringpublic static <T> String hierarchicIndexOf(T member, HierarchicClustering<T,? extends HierarchicCluster<T>> 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 accessible 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.
T
- Type of clustered membersmember
- A memberclustering
- Associated clusteringIllegalArgumentException
- when the given member is not part of the given clusteringpublic static void traverseSimplePreOrderDfs(IDBasedHierarchicClustering h, SimpleDfsVisitor preOrderVisitor)
traverseSimpleDfs(com.chemaxon.clustering.common.IDBasedHierarchicClustering, com.chemaxon.clustering.util.SimpleDfsVisitor, com.chemaxon.clustering.util.SimpleDfsVisitor)
.h
- Hierarchy to traversepreOrderVisitor
- A non-null
visitor to invokepublic static void traverseSimplePostOrderDfs(IDBasedHierarchicClustering h, SimpleDfsVisitor postOrderVisitor)
traverseSimpleDfs(com.chemaxon.clustering.common.IDBasedHierarchicClustering, com.chemaxon.clustering.util.SimpleDfsVisitor, com.chemaxon.clustering.util.SimpleDfsVisitor)
.h
- Hierarchy to traversepostOrderVisitor
- A non-null
visitor to invokepublic static void traverseSimpleDfs(IDBasedHierarchicClustering h, SimpleDfsVisitor preorderVisitorOrNull, SimpleDfsVisitor postorderVisitorOrNull)
List
based stack. Leaves and
members must be handled by the visitor implementation.
For the following tree (only clusters shown, no leaves/members considered)
C-0 C-1 -+- C-2 --- C-3 +- C-4 C-5 C-6 --- C-7 --- C-8
The following invocation order is expected (<PATH> / <VISITED>
) for the preorder callback:
"C-0" / "C-0" "C-1" / "C-1" "C-1", "C-2" / "C-2" "C-1", "C-2", "C-3" / "C-3" "C-1", "C-4" / "C-4" "C-5" / "C-5" "C-6" / "C-6" "C-6", "C-7" / "C-7" "C-6", "C-7", "C-8" / "C-8"
The following invocation order is expected (<PATH> / <VISITED>
) for the postorder callback:
"C-0" / "C-0" "C-1", "C-2", "C-3" / "C-3" "C-1", "C-2" / "C-2" "C-1", "C-4" / "C-4" "C-1" / "C-1" "C-5" / "C-5" "C-6", "C-7", "C-8" / "C-8" "C-6", "C-7" / "C-7" "C-6" / "C-6"
h
- ClusteringpreorderVisitorOrNull
- Visitor to be invoked before a descend step or null
postorderVisitorOrNull
- Visitor to be invoked after an ascend or side step or null
public static DissimilarityInput linearEuclideanDissimilarityInput(double[] values)
DissimilarityInput
over a set of 1D values.values
- Values to considerpublic static <T> List<T> traversePostOrderDFS(PostOrderDfsVisitor<T> visitor, IDBasedHierarchicClustering clustering)
T
- Traversal result typevisitor
- Callback interface for traversal/skippingclustering
- Clustering to traversepublic static String hierarchyToString(IDBasedHierarchicClustering clustering, IDBasedAssigner levels, List<String> labels, int cols)
clustering
- Source clustering to uselevels
- Level assignemnt to uselabels
- Leaf labels for leaf IDscols
- Total columns