private int calculateDimensionX(V v) { int size = 0; int childrenNum = graph.getSuccessors(v).size(); if (childrenNum != 0) { for (V element : graph.getSuccessors(v)) { size += calculateDimensionX(element) + distX; } } size = Math.max(0, size - distX); basePositions.put(v, size); return size; }
private int calculateDimensionX(Collection<V> roots) { int size = 0; for(V v : roots) { int childrenNum = graph.getSuccessors(v).size(); if (childrenNum != 0) { for (V element : graph.getSuccessors(v)) { size += calculateDimensionX(element) + distX; } } size = Math.max(0, size - distX); basePositions.put(v, size); } return size; }
private int calculateDimensionX(V v) { int size = 0; int childrenNum = graph.getSuccessors(v).size(); if (childrenNum != 0) { for (V element : graph.getSuccessors(v)) { size += calculateDimensionX(element) + distX; } } size = Math.max(0, size - distX); basePositions.put(v, size); return size; }
private int calculateDimensionX(Collection<V> roots) { int size = 0; for(V v : roots) { int childrenNum = graph.getSuccessors(v).size(); if (childrenNum != 0) { for (V element : graph.getSuccessors(v)) { size += calculateDimensionX(element) + distX; } } size = Math.max(0, size - distX); basePositions.put(v, size); } return size; }
protected void buildTree(V v, int x) { if (!alreadyDone.contains(v)) { alreadyDone.add(v); //go one level further down this.m_currentPoint.y += this.distY; this.m_currentPoint.x = x; this.setCurrentPositionFor(v); int sizeXofCurrent = basePositions.get(v); int lastX = x - sizeXofCurrent / 2; int sizeXofChild; int startXofChild; for (V element : graph.getSuccessors(v)) { sizeXofChild = this.basePositions.get(element); startXofChild = lastX + sizeXofChild / 2; buildTree(element, startXofChild); lastX = lastX + sizeXofChild + distX; } this.m_currentPoint.y -= this.distY; } }
protected void buildTree(V v, int x) { if (alreadyDone.add(v)) { //go one level further down this.m_currentPoint.y += this.distY; this.m_currentPoint.x = x; this.setCurrentPositionFor(v); int sizeXofCurrent = basePositions.get(v); int lastX = x - sizeXofCurrent / 2; int sizeXofChild; int startXofChild; for (V element : graph.getSuccessors(v)) { sizeXofChild = this.basePositions.get(element); startXofChild = lastX + sizeXofChild / 2; buildTree(element, startXofChild); lastX = lastX + sizeXofChild + distX; } this.m_currentPoint.y -= this.distY; } }
/** * Populates <code>subtree</code> with the subtree of <code>tree</code> * which is rooted at <code>root</code>. * @param <V> the vertex type * @param <E> the edge type * @param tree the tree whose subtree is to be extracted * @param subTree the tree instance which is to be populated with the subtree of <code>tree</code> * @param root the root of the subtree to be extracted */ public static <V,E> void growSubTree(Forest<V,E> tree, Forest<V,E> subTree, V root) { if(tree.getSuccessorCount(root) > 0) { Collection<E> edges = tree.getOutEdges(root); for(E e : edges) { subTree.addEdge(e, tree.getEndpoints(e)); } Collection<V> kids = tree.getSuccessors(root); for(V kid : kids) { growSubTree(tree, subTree, kid); } } }
/** * Populates <code>subtree</code> with the subtree of <code>tree</code> * which is rooted at <code>root</code>. * * @param <V> * the vertex type * @param <E> * the edge type * @param tree * the tree whose subtree is to be extracted * @param subTree * the tree instance which is to be populated with the subtree of * <code>tree</code> * @param root * the root of the subtree to be extracted */ public static <V, E> void growSubTree(Forest<V, E> tree, Forest<V, E> subTree, V root) { if (tree.getSuccessorCount(root) > 0) { Collection<E> edges = tree.getOutEdges(root); for (E e : edges) { subTree.addEdge(e, tree.getEndpoints(e)); } Collection<V> kids = tree.getSuccessors(root); for (V kid : kids) { growSubTree(tree, subTree, kid); } } }