/** * Returns the String representation of the Partition. * * @see Object#toString() */ public String toString() { Iterator i = this.getLeavesIterator(); String s = "["; while (i.hasNext()) { s = s + (i.next() + ","); } s = s.substring(0, s.length() - 1) + "]"; return s; }
/** * Checks if this partition is subset of another partition. * if the other partition contains all leaves of this parititon * 1 will be returned otherwise 0. */ public int isSubset(Partition otherPartition) { if (otherPartition == null) return 0; Iterator myLeavesIterator = getLeavesIterator(); while (myLeavesIterator.hasNext()) { Object key = myLeavesIterator.next(); Object value = otherPartition.getNode(key); if (value == null) {//alle Nodes der Partition muessen in der anderen vorkommen return 0; } } return 1; }
/** * Returns a String representation of the Partition. * Better use the toString Method. * * @return String The String representation. * @deprecated Use the standart toString() Method! */ public String toHashString() { Iterator i = this.getLeavesIterator(); Vector leaves = new Vector(); int n = 0; while (i.hasNext()) { int j = 0; Object next = i.next(); while (j < leaves.size()) { if (leaves.elementAt(j).toString().compareTo(next.toString()) > 0) { break; } j++; } leaves.insertElementAt(next, j); } String orderedHash = new String(); for (int j = 0; j < leaves.size(); j++) { orderedHash = orderedHash + leaves.elementAt(j).toString() + ","; } orderedHash = orderedHash.substring(0, orderedHash.length() - 1); return orderedHash; }
/** * Add a partition onto this one. * * @param p Partition */ public void add(Partition p) { Iterator i = p.getLeavesIterator(); while (i.hasNext()) { TreeNode n = (TreeNode) i.next(); //System.out.println("Try to add node from partition " + n); this.add(p.getNode(n)); //System.out.println(" done"); } }
myLeavesIterator = getLeavesIterator();
Iterator it = sPartition.getLeavesIterator();
switch (p[i].getSize()) { case 1: id = p[i].getLeavesIterator().next(); result.addVertex(newNode); result.addEdge(node, newNode); Iterator it = p[i].getLeavesIterator(); while (it.hasNext()) { id = it.next();