java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.multisource.dispatchers.MergeOrder
All Implemented Interfaces:
Serializable

public class MergeOrder extends Object implements 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 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

      private List<String> labels
  • Constructor Details

    • MergeOrder

      public MergeOrder(int[][] tree)
    • MergeOrder

      public MergeOrder(int[][] tree, List<String> labels)
    • MergeOrder

      public MergeOrder(int[][] tree, double[] distances)
    • MergeOrder

      public MergeOrder(int[][] tree, double[] distances, List<String> labels)
  • 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

      public List<String> getLabels()
    • setLabels

      public void setLabels(List<String> labels)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • 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

      public boolean serializeToFile(File file)
      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

      public static MergeOrder loadFromFile(File file)
    • writeToFile

      public void writeToFile(File file)
      Write the tree to file. This format is human readable and can't be used for serialization. The format looks like
       79998
       ├── 79855
       │   ├── 78859
       │   │   ├── 73335
       │   │   │   ├── 49126
       │   │   │   │   ├── 267534~en~tauschrausch.nt
       │   │   │   │   └── 972074~en~studieloopbaan.nt
       │   │   │   └── 72061
       │   │   │       ├── 1056364~en~atlan.nt
       │   │   │       └── 69495
       
      Parameters:
      file - the destination
    • printTreeNode

      private void printTreeNode(TreeNode node, PrintWriter writer, String prefix, String childrenPrefix)
    • getLabel

      public String getLabel(int pos)
    • isLeaf

      public boolean isLeaf(int pos)
    • displayTree

      public void displayTree()
      Displays the tree in a JFrame to interatcively look at the tree.
    • getJTree

      protected TreeNode getJTree()
    • getCountOfParallelExecutions

      public List<Integer> getCountOfParallelExecutions()
      Returns a list of numbers which represents the count of merges which can performed in this step.
      Returns:
      a list of numbers