/** * Compares this Partition to another Partition. * <p> * Returns 0 if both are equal, this means they have the same size and * contain the same Elements. A negative Value is returned if the size of * this Partition is smaller than the size of the other Partition. A positive * Value is returned if the size of this Patition is larger than the size of the * other one. If both Partitons have the same size but do not contain the same Elements, * an Exception is thrown. * * @param otherPartition * @return int */ public int compareTo(Partition otherPartition) throws Exception { if (this.getSize() < otherPartition.getSize()) return -1; if (this.getSize() > otherPartition.getSize()) return 1; if (this.equals(otherPartition)) return 0; throw new Exception(); }
/** * method first compare the size of two nodes, if the size is the same * the equals method is called * * @return -1 if node 1 < node 2, * 1 if node 1 > node 2, else equals (node 1,node2) */ public int compare(TreeNode node1, TreeNode node2) { if (node1 == null || node2 == null) { throw new ClassCastException(); } if (node1.getPartition().getSize() < node2.getPartition().getSize()) { return -1; } else if (node1.getPartition().getSize() > node2.getPartition().getSize()) { return 1; } return equals(node1, node2); }
public Edge getDistanceEdge(TreeNode source, TreeNode target) { int intersection = 0; double s = 0; for (TreeNode treeNodeSource : source.getPartition() .getLeavesArray()) { for (TreeNode treeNodeTarget : target.getPartition() .getLeavesArray()) { if (treeNodeSource.getLabel().equals( treeNodeTarget.getLabel())) { // if (treeNodeSource.equals(treeNodeTarget)){ intersection++; } } } s = (intersection / (Math.pow( (double) (source.getPartition().getSize() + target .getPartition().getSize()), parameter))); return new Edge(source, target, s); }
public Edge getDistanceEdge(TreeNode source, TreeNode target) { // //System.out.println("getDistance Methode: Source treeNode partition --> "+source.getPartition().toString()); // //System.out.println("getDistance Methode: Target treeNode partition --> "+target.getPartition().toString()); int intersection = 0; int union = 0; double s = 0; for (TreeNode treeNodeSource : source.getPartition() .getLeavesArray()) { for (TreeNode treeNodeTarget : target.getPartition() .getLeavesArray()) { if (treeNodeSource.getLabel().equals( treeNodeTarget.getLabel())) { // if (treeNodeSource.equals(treeNodeTarget)){ intersection++; } } } // //System.out.println("getDistance Methode: intersection --> "+intersection); union = source.getPartition().getSize() + target.getPartition().getSize() - intersection; // //System.out.println("getDistance Methode: union --> "+union); s = (double) intersection / (double) union; // //System.out.println("getDistance Methdode: Distance --> "+s); return new Edge(source, target, s); }
public Edge getDistanceEdge(TreeNode source, TreeNode target) { int intersection = 0; double s = 0; for (TreeNode treeNodeSource : source.getPartition() .getLeavesArray()) { for (TreeNode treeNodeTarget : target.getPartition() .getLeavesArray()) { if (treeNodeSource.getLabel().equals( treeNodeTarget.getLabel())) { // if (treeNodeSource.equals(treeNodeTarget)){ intersection++; } } } // //System.out.println("getDistance Methode likelihoods: intersection --> "+intersection); TreeNode getRootHelp = source; while (getRootHelp.getParent() != null) { getRootHelp = getRootHelp.getParent(); } int allLeaves = getRootHelp.getLeaves().length; s = BCNWithLikelihoods.computeValueWithDouble(allLeaves, source .getPartition().getSize(), target.getPartition().getSize(), intersection); return new Edge(source, target, s); }
Object id; TreeNode newNode; switch (p[i].getSize()) { case 1: id = p[i].getLeavesIterator().next();