I know how to change the size of the vertex, but when I do that, the TreeLayout places the nodes such that the edges vanish ie. the nodes overlap and the edges are not visible. If I change the layout (to KKLayout), the edges are automatically made larger and the graph looks clean. I want to know if it is possible to space the nodes apart/increase length of an edge in the TreeLayout itself? (Any other suggestions maintaining the tree hierarchy are also great)
You can define the space between nodes when you construct your TreeLayout
. This would increase the edge length:
TreeLayout treeLayout = new TreeLayout<String, Integer>(graph, 500, 500);
If you don't enter a value for distx
or disty
then it defaults to 50. Constructor:
/**
* Creates an instance for the specified graph, X distance, and Y distance.
*/
public TreeLayout(Forest<V,E> g, int distx, int disty) {
if (g == null)
throw new IllegalArgumentException("Graph must be non-null");
if (distx < 1 || disty < 1)
throw new IllegalArgumentException("X and Y distances must each be positive");
this.graph = g;
this.distX = distx;
this.distY = disty;
buildTree();
}