There are two nodes that are far away because there is no link connection.
Q1:I want these two nodes to be closer to the other nodes.Could you give me some advice?
Q2:Computations stop when no vertex moves more than epsilonDistance or when maxIterations have happened.Can I let the computations never stop?
In your case you’ll want to set ArrangingLayout.primaryLayout to be your ForceDirectedLayout. Disconnected nodes it will automatically arrange along the bottom of the document by a GridLayout.
The ArrangingForceDirectedLayout is what most people want.
But an alternative design is to customize the ForceDirectedLayout so that there are pretend links/edges between the single (disconnected) nodes/vertexes and other already-connected nodes/vertexes.
I notice now that I didn’t answer your second question. There are a number of possibliities. Perhaps you would be interested in Interactive Force Directed Layout ?