brunomnsilva / JavaFXSmartGraph

Generic (Java FX) Graph Visualization Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node overlap

thomakl opened this issue · comments

commented

Hi,

I have an issue with overlapping nodes.
Every time I insert an element in the graph, I update it with graphView.update().
I am currently putting on the graph around 70 nodes in row.

Do you think the issue has something to do with the "smartgraph.properties" and the Force-directed layout ? Or graphView.updateAndWait() could do the trick ?

NB : there are currently no edge in the graph

Screen Shot 2020-03-24 at 14 38 07

_Figure 1 : Node overlap_

Screen Shot 2020-03-24 at 14 42 47

_Figure 1 : Node overlap after I drag the top node of the stack_

Thank you for you help

TL

The problem has two causes:

  • you're using the automatic layout, and
  • the nodes are isolated, i.e., they are not connected.

As per documentation, currently when you add a new isolated node, it will be placed in the center of the pane. Since you are adding several isolated nodes, they are all overlapping at the same coordinates. In this case, the force directed algorithm reaches an edge case and does not repulse the nodes.

When you move the top node, than the algorithm is able to kick in and, the consequence, is that all nodes are repulsed to the edge of the pane, since there are no attractive forces from edges.

I should maybe include a node arrangement strategy that uses a fixed layout, but repositions the nodes when new nodes are inserted.