Class MergeOrder
java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.multisource.dispatchers.MergeOrder
- All Implemented Interfaces:
Serializable
The information of how KGs should be merged together (in which order).
The main info is contained in the tree as int[][].
The data structure is the same as in the result of the scipy linkage function
and the hierarchical clustering of the smile library.
In the i-th iteration, clusters with indices tree[i, 0] and tree[i, 1] are combined to form a cluster with index n+i.
A cluster with an index less than n, corresponds to one of the original observations.
The distance between clusters tree[i, 0] and tree[i, 1] is given by distance[i].
Equals and hash are overriden in such a way, that tree[i, 0] and tree[i, 1] may be switched but the order (i) need to be the same.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate final double[]
private final int
private static final org.slf4j.Logger
private final int
private static final long
private final int[][]
-
Constructor Summary
ConstructorDescriptionMergeOrder
(int[][] tree) MergeOrder
(int[][] tree, double[] distances) MergeOrder
(int[][] tree, double[] distances, List<String> labels) MergeOrder
(int[][] tree, List<String> labels) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Displays the tree in a JFrame to interatcively look at the tree.boolean
private static boolean
equalsDistances
(double[] a, double[] a2, double eps) private static boolean
equalsTree
(int[][] a1, int[][] a2) private static boolean
equalsTreeElement
(int[] a1, int[] a2) Returns a list of numbers which represents the count of merges which can performed in this step.private static double[]
getDefaultDistances
(int[][] tree) double[]
Return the distances between the clusters.double[]
Return the normalized distances between the clusters.int
Return the height of the merge tree.protected TreeNode
getJTree()
getLabel
(int pos) int[][]
getTree()
Returns the merge tree as int[][].int
hashCode()
boolean
Returns true if the height variable is set to some non default value.boolean
isLeaf
(int pos) static MergeOrder
loadFromFile
(File file) private void
printTreeNode
(TreeNode node, PrintWriter writer, String prefix, String childrenPrefix) boolean
serializeToFile
(File file) Serializes this object to the given file.void
void
writeToFile
(File file) Write the tree to file.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
serialVersionUID
private static final long serialVersionUID- See Also:
-
numberOfExamples
private final int numberOfExamples -
tree
private final int[][] tree -
distances
private final double[] distances -
height
private final int height -
labels
-
-
Constructor Details
-
MergeOrder
public MergeOrder(int[][] tree) -
MergeOrder
-
MergeOrder
public MergeOrder(int[][] tree, double[] distances) -
MergeOrder
-
-
Method Details
-
getDefaultDistances
private static double[] getDefaultDistances(int[][] tree) -
getTree
public int[][] getTree()Returns the merge tree as int[][]. The data structure is the same as in the result of the scipy linkage function and the hierarchical clustering of the smile library. In the i-th iteration, clusters with indices tree[i, 0] and tree[i, 1] are combined to form a cluster with index n+i. A cluster with an index less than n, corresponds to one of the original observations. The distance between clusters tree[i, 0] and tree[i, 1] is given by distance[i].- Returns:
- the merge tree as int[][]
-
getDistances
public double[] getDistances()Return the distances between the clusters.- Returns:
- the distances between the clusters
-
getDistancesNormalized
public double[] getDistancesNormalized()Return the normalized distances between the clusters.- Returns:
- the normalized distances between the clusters
-
isDistancesSet
public boolean isDistancesSet()Returns true if the height variable is set to some non default value. Returns false if the values are all set to the default of 1.0.- Returns:
- true if the height variable is set to some non default value, false otherwiese.
-
getHeight
public int getHeight()Return the height of the merge tree.- Returns:
- the height of the tree
-
getLabels
-
setLabels
-
hashCode
public int hashCode() -
equals
-
equalsTree
private static boolean equalsTree(int[][] a1, int[][] a2) -
equalsTreeElement
private static boolean equalsTreeElement(int[] a1, int[] a2) -
equalsDistances
private static boolean equalsDistances(double[] a, double[] a2, double eps) -
serializeToFile
Serializes this object to the given file.- Parameters:
file
- the file where this objetc should be serialized to- Returns:
- true if everything worked, false if exception occured (which is logged)
-
loadFromFile
-
writeToFile
Write the tree to file. This format is human readable and can't be used for serialization. The format looks like79998 ├── 79855 │ ├── 78859 │ │ ├── 73335 │ │ │ ├── 49126 │ │ │ │ ├── 267534~en~tauschrausch.nt │ │ │ │ └── 972074~en~studieloopbaan.nt │ │ │ └── 72061 │ │ │ ├── 1056364~en~atlan.nt │ │ │ └── 69495
- Parameters:
file
- the destination
-
printTreeNode
-
getLabel
-
isLeaf
public boolean isLeaf(int pos) -
displayTree
public void displayTree()Displays the tree in a JFrame to interatcively look at the tree. -
getJTree
-
getCountOfParallelExecutions
Returns a list of numbers which represents the count of merges which can performed in this step.- Returns:
- a list of numbers
-