I would like to implement a graph in Java. I defined class `Node` and class `Edge`, and the graph is represented with a list of Node, and for each node, a list of edges starting from the node is defined as a field of the node. Now I would like to use some Java library to visualize the graph.

Currently I have tried [graphviz-java](https://github.com/nidi3/graphviz-java). The result meets my requirement but the edges and nodes are not placed well. See the following graph below:

![graphviz-java result](https://hrqnanjing-1256948370.cos.ap-shanghai.myqcloud.com/2019-04-22-081554.png)

I created the graph with the API it provided like `node(xxx)`, `addLink()` through traversing the node list of my graph instead of generating the raw dot file text.

The key code of creating the graph is as follows:

```java
for (LiteralNode litNode : literalNodeArrayList) 
{     
    MutableNode mutableNode = mutNode(litNode.getNodeElement());     
    for (Edge e : litNode.getEdgeList()) {         
    MutableNode endNode = mutNode(e.endNode.getNodeElement());
    mutableNode.addLink(to(endNode.port(Compass.NORTH)).add(Arrow.VEE)); 
}     
    mutableNodes.add(mutableNode);     
    g.add(mutableNode); 
}

```

It's basically simple traverse with loops. The node and edges are dynamically changed according to different cases.

I would like the node and edges adjust the location to make the graph display better. I have also tried using json file and d3js to visualize the graph but I found those libraries focus too much on displaying huge amount of nodes and their distributions, which I don't need. I like the structure graphviz provided with some stratification. So I would like to get some recommendation. 

I mentioned the json file because if no Java library is available, I might as well try some javascript library like d3js and only use java as a backend tool to generate json file I need to input. So the recommendation is not limited to Java.