Jonathan's answer is incorrect, you do not need to update the graph object on the EDT.
Your VisualizationViewer
should always be on the EDT, yes, but using functions like addVertex
or addEdge
can be called from any thread. The important thing to remember is that you cannot call vv.repaint()
from the same thread that you are updating on.
I achieve this by adding a PropertyChangeListener
on the JPanel
holding the VisualizationViewer
. This listens to changes in the graph and calls repaint accordingly.