Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop in FruchtermanReingoldLayout. #8217

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void rePerformLayout(int iters) {
// System.out.println("scene bounds are =" + bounds);
temp = bounds.getWidth() / 1000;
// forceConstant = 0.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds);
forceConstant = 0.25 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds);
forceConstant = 1.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds);
// System.out.println("force constant2=" + forceConstant);
performLayout(false);
}
Expand All @@ -150,7 +150,7 @@ private void init() {
bounds = new Rectangle(magicSizeConstant + (magicSizeMultiplier * nds),
magicSizeConstant + (magicSizeMultiplier * nds)); //g.getMaximumBounds();
temp = bounds.getWidth() / 10;
forceConstant = 0.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds);
forceConstant = 1.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds);
mbien marked this conversation as resolved.
Show resolved Hide resolved

GraphNode<I> rn = scene.getRootGraphNode();
NodeWidget rw = getWidget(rn);
Expand Down Expand Up @@ -382,7 +382,8 @@ private void relayoutNonFixed(NodeWidget w) {
r = 30;
theta = 0;
w.setFixed(false);
while (true) {
// 48 - ~3 times round?
for (int i = 0; i < 48; i++) {
mbien marked this conversation as resolved.
Show resolved Hide resolved
AffineTransform tr = AffineTransform.getRotateInstance(theta);
Point2D d2point = tr.transform(new Point2D.Double(0, r), null);
Point point = new Point((int)d2point.getX() + masterPoint.x, (int)d2point.getY() + masterPoint.y);
Expand All @@ -396,10 +397,9 @@ private void relayoutNonFixed(NodeWidget w) {
if (theta > (Math.PI * 2 - Math.PI / 10)) {
r = r + 30;
theta = theta - Math.PI * 2;
thetaStep = thetaStep * 3 / 4;
thetaStep = thetaStep * 3 / 4;
}
}

}

private NodeWidget getWidget(GraphNode n) {
Expand Down
Loading