Skip to content

Instantly share code, notes, and snippets.

@benjaminaaron
Created May 9, 2015 16:49
Show Gist options
  • Save benjaminaaron/6f95c3dca98c124acd15 to your computer and use it in GitHub Desktop.
Save benjaminaaron/6f95c3dca98c124acd15 to your computer and use it in GitHub Desktop.
Trying to achieve a simple Tree-Layout with graphstream
import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.SingleGraph;
import org.graphstream.ui.layout.HierarchicalLayout;
import org.graphstream.ui.view.Viewer;
public class Simple {
public static void main(String[] args) {
Graph graph = new SingleGraph("Test");
Viewer viewer = graph.display();
HierarchicalLayout hl = new HierarchicalLayout();
viewer.enableAutoLayout(hl);
graph.addNode("A" );
graph.addNode("B" );
graph.addNode("C" );
graph.addNode("D" );
graph.addEdge("AB", "A", "B");
graph.addEdge("AC", "A", "C");
graph.addEdge("CD", "C", "D");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment