Skip to content

Commit 9db302d

Browse files
mbastianclaude
andcommitted
Don't give NaN positions to nodes without size
The layouts space nodes by their size, so a graph whose nodes all have size 0 (or a single such node) made the circumference 0 and the angle Infinity, giving NaN positions that graphstore rejects. Use a minimum size of 1 in the circumference and angle computations. Version 0.9.4. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 76ba398 commit 9db302d

5 files changed

Lines changed: 21 additions & 10 deletions

File tree

‎modules/CircularLayout/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<groupId>org.gephi.layout.plugin</groupId>
1111
<artifactId>circularlayout</artifactId>
12-
<version>0.9.3</version>
12+
<version>0.9.4</version>
1313
<packaging>nbm</packaging>
1414

1515
<name>CircularLayout</name>

‎modules/CircularLayout/src/main/java/org/gephi/layout/plugin/circularlayout/circlelayout/CircleLayout.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void initAlgo()
7878
{
7979
if (!n.isFixed())
8080
{
81-
tmpcirc += (n.size() * 2);
81+
tmpcirc += (nodeSize(n) * 2);
8282
}
8383
}
8484
tmpcirc = (tmpcirc * 1.2);
@@ -109,7 +109,7 @@ public void initAlgo()
109109
{
110110
if (this.isNodePlacementNoOverlap())
111111
{
112-
noderadius = (n.size());
112+
noderadius = (nodeSize(n));
113113
double noderadian = (theta * noderadius * 1.2);
114114
nodeCoords = this.cartCoors(radius, 1, lasttheta + noderadian);
115115
lasttheta += (noderadius * 2 * theta * 1.2);

‎modules/CircularLayout/src/main/java/org/gephi/layout/plugin/circularlayout/dualcirclelayout/DualCircleLayout.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public void initAlgo()
9090
{
9191
if (index < this.secondarynodecount)
9292
{
93-
tmpsecondarycirc += (n.size() * 2);
93+
tmpsecondarycirc += (nodeSize(n) * 2);
9494
}
9595
else
9696
{
97-
tmpprimarycirc += (n.size() * 2);
97+
tmpprimarycirc += (nodeSize(n) * 2);
9898
}
9999
index++;
100100
}
@@ -137,7 +137,7 @@ public void initAlgo()
137137
if (index < this.secondarynodecount)
138138
{
139139
//Draw secondary circle
140-
double noderadius = (n.size());
140+
double noderadius = (nodeSize(n));
141141
//This step is hackish... but it makes small numbers of nodes symetrical on both the secondary circles.
142142
if (secondary_scale > 2)
143143
{
@@ -153,7 +153,7 @@ public void initAlgo()
153153
}
154154
else
155155
{
156-
double noderadius = (n.size());
156+
double noderadius = (nodeSize(n));
157157
double noderadian = (primary_theta * noderadius * 1.2 * primary_scale);
158158
if (index == this.secondarynodecount)
159159
{

‎modules/CircularLayout/src/main/java/org/gephi/layout/plugin/circularlayout/layouthelper/LayoutHelper.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
*/
4444
public abstract class LayoutHelper implements Layout
4545
{
46+
private static final double MIN_NODE_SIZE = 1.0;
47+
4648
private final LayoutBuilder layoutBuilder;
4749
protected GraphModel graphModel;
4850
private boolean converged;
@@ -284,6 +286,15 @@ public static Map getRotationMap()
284286
return map;
285287
}
286288

289+
/**
290+
* The room a node takes on the circle. Nodes are spaced by their size, so a node without size (e.g. one that was
291+
* ranked down to zero) would give a circle with no circumference and NaN positions.
292+
*/
293+
protected static double nodeSize(Node n)
294+
{
295+
return Math.max(n.size(), MIN_NODE_SIZE);
296+
}
297+
287298
public float[] cartCoors(double radius, int whichInt, double theta)
288299
{
289300
float[] coOrds = new float[2];

‎modules/CircularLayout/src/main/java/org/gephi/layout/plugin/circularlayout/radialaxislayout/RadialAxisLayout.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ else if ("BOTTOM".equals(this.strKnockdown))
201201
}
202202
if (order == 0)
203203
{
204-
double noderadius = n.size();
204+
double noderadius = nodeSize(n);
205205
circ += noderadius * 2;
206206
SparBaseList.add(n);
207207
}
@@ -230,7 +230,7 @@ else if ("BOTTOM".equals(this.strKnockdown))
230230
double[] ArraySparTheta = new double[(int)SparArrayCount];
231231
for (Node n : SparBaseList)
232232
{
233-
double noderadius = (n.size());
233+
double noderadius = (nodeSize(n));
234234
double noderadian = (theta * noderadius * this.dScalingWidth);
235235
ArraySparTheta[group] = lasttheta + noderadian;
236236
ArraySparLength[group] = noderadius * this.dScalingWidth;
@@ -256,7 +256,7 @@ else if ("BOTTOM".equals(this.strKnockdown))
256256
tmpsparlength = ArraySparLength[position.group];
257257
tmpspartheta = ArraySparTheta[position.group];
258258

259-
double noderadius = (n.size());
259+
double noderadius = (nodeSize(n));
260260
if (this.boolSparSpiral)
261261
{
262262
nodeCoords = this.cartCoors(tmpsparlength + radius + (noderadius * this.dScalingWidth), 1, tmpspartheta + (position.order * (thetainc / SparNodeCount[position.group])));

0 commit comments

Comments
 (0)