I implement a graph algorithm and I have to make an interface for it. A frame with every step. I will do it manually. I use the Jung package but I can't figure out how to make that graph to look like a tree. I'm struggling for two days.
Here is my attempt:
DirectedSparseGraph<String, ?> g = new DirectedSparseGraph<String, Object>();
g.addVertex("ROOT");
g.addVertex("A");
g.addVertex("B");
g.addVertex("C");
g.addVertex("D");
g.addVertex("E");
VisualizationImageServer vv = new VisualizationImageServer(new CircleLayout(g), new Dimension(350, 300));
JFrame frame = new JFrame("First step");
frame.getContentPane().add(vv);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
There I used CircleLayout, I should use TreeLayout but I have to implement Forest interface and I don't know how, I'm not a bright programmer. :(
I want my graph to look like this: