Fix node size calculation bugs
This commit is contained in:
@@ -464,7 +464,7 @@ const useLightrangeGraph = () => {
|
|||||||
const nodesToAdd = new Set<string>();
|
const nodesToAdd = new Set<string>();
|
||||||
const edgesToAdd = new Set<string>();
|
const edgesToAdd = new Set<string>();
|
||||||
|
|
||||||
// Get degree range from existing graph for size calculations
|
// Get degree maxDegree from existing graph for size calculations
|
||||||
const minDegree = 1;
|
const minDegree = 1;
|
||||||
let maxDegree = 0;
|
let maxDegree = 0;
|
||||||
sigmaGraph.forEachNode(node => {
|
sigmaGraph.forEachNode(node => {
|
||||||
@@ -472,10 +472,6 @@ const useLightrangeGraph = () => {
|
|||||||
maxDegree = Math.max(maxDegree, degree);
|
maxDegree = Math.max(maxDegree, degree);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Calculate size formula parameters
|
|
||||||
const range = maxDegree - minDegree || 1; // Avoid division by zero
|
|
||||||
const scale = Constants.maxNodeSize - Constants.minNodeSize;
|
|
||||||
|
|
||||||
// First identify connectable nodes (nodes connected to the expanded node)
|
// First identify connectable nodes (nodes connected to the expanded node)
|
||||||
for (const node of processedNodes) {
|
for (const node of processedNodes) {
|
||||||
// Skip if node already exists
|
// Skip if node already exists
|
||||||
@@ -587,6 +583,9 @@ const useLightrangeGraph = () => {
|
|||||||
maxDegree = Math.max(maxDegree, projectedDegree);
|
maxDegree = Math.max(maxDegree, projectedDegree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const range = maxDegree - minDegree || 1; // Avoid division by zero
|
||||||
|
const scale = Constants.maxNodeSize - Constants.minNodeSize;
|
||||||
|
|
||||||
// SAdd nodes and edges to the graph
|
// SAdd nodes and edges to the graph
|
||||||
// Calculate camera ratio and spread factor once before the loop
|
// Calculate camera ratio and spread factor once before the loop
|
||||||
const cameraRatio = useGraphStore.getState().sigmaInstance?.getCamera().ratio || 1;
|
const cameraRatio = useGraphStore.getState().sigmaInstance?.getCamera().ratio || 1;
|
||||||
|
Reference in New Issue
Block a user