This is my code and the output is not in the form of an hierarchical tree
public class Simple {
public static void main(String[] args) {
Graph graph = new SingleGraph("Test");
Viewer viewer = graph.display(false);
HierarchicalLayout hl = new HierarchicalLayout();
viewer.enableAutoLayout(hl);
graph.setStrict(false);
graph.setAutoCreate(false);
graph.addNode("A" );
graph.addNode("B" );
graph.addNode("C" );
graph.addNode("D");
graph.addNode("E");
graph.getNode("A").addAttribute("ui.label", "A");
graph.getNode("B").addAttribute("ui.label", "B");
graph.addEdge("A-B", "A", "B",true);
graph.addEdge("A-C", "A", "C",true);
graph.addEdge("B-D", "B", "D",true);
graph.addEdge("B-E", "B", "E",true);
The nodes are placed randomly even though I used the hierarchical layout.
I am trying to draw a tree as seen in the following picture:
.