mirror of
https://github.com/yacy/yacy_search_server.git
synced 2025-02-02 06:38:42 -05:00
8edaccfedf
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7592 6c8d7289-2bf4-0310-a012-ef5d649a1542
42 lines
978 B
Java
42 lines
978 B
Java
package net.yacy.visualization;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class GridTree {
|
|
|
|
private List<GridTree> children;
|
|
|
|
public GridTree() {
|
|
this.children = null;
|
|
}
|
|
|
|
public void addChild(GridTree child) {
|
|
if (this.children == null) this.children = new ArrayList<GridTree>();
|
|
this.children.add(child);
|
|
}
|
|
|
|
public boolean isLeaf() {
|
|
return this.children == null;
|
|
}
|
|
|
|
public int depth() {
|
|
if (this.isLeaf()) return 1;
|
|
int maxChildDepth = 0;
|
|
for (GridTree child: children) {
|
|
maxChildDepth = Math.max(maxChildDepth, child.depth());
|
|
}
|
|
return maxChildDepth + 1;
|
|
}
|
|
|
|
public int width() {
|
|
if (this.isLeaf()) return 1;
|
|
int maxChildDepth = 0;
|
|
for (GridTree child: children) {
|
|
maxChildDepth = Math.max(maxChildDepth, child.depth());
|
|
}
|
|
return maxChildDepth + 1;
|
|
}
|
|
|
|
}
|