Skip to content

Commit

Permalink
fix: Adjust canvas and SVG sizing, remove unused code, and reduce ini…
Browse files Browse the repository at this point in the history
…tial network size
  • Loading branch information
sanity committed Nov 27, 2024
1 parent 14144b8 commit a38c0a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
6 changes: 3 additions & 3 deletions hugo-site/layouts/shortcodes/small-world-scale.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
</button>
</div>
<div style="display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 1rem;">
<canvas id="networkCanvas3" width="500" height="500" style="max-width: 70%; height: auto;"></canvas>
<div id="scalingChart" style="width: min(600px, 70%); height: 600px;">
<svg width="600" height="600" style="max-width: 70%; height: auto;"></svg>
<canvas id="networkCanvas3" width="500" height="500" style="width: 500px; height: 500px;"></canvas>
<div id="scalingChart" style="width: 500px; height: 500px;">
<svg width="500" height="500"></svg>
</div>
</div>
<div style="margin-bottom: 2rem;"></div>
Expand Down
16 changes: 1 addition & 15 deletions hugo-site/static/js/small-world-scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,6 @@ waitForD3().then(() => {
}
}

// Select evenly spaced reference nodes
for (let i = 0; i < numReferenceNodes; i++) {
referenceNodes.push(peers[i * stride]);
}

// Increased sampling for better averages
const samplesPerRef = Math.min(
Math.ceil(numPeers * 0.9), // Sample up to 90% of nodes
90 // but cap at 90 samples per reference node
);

let totalLength = 0;
let pathCount = 0;

return pathCount > 0 ? totalLength / pathCount : 0;
}

Expand Down Expand Up @@ -464,7 +450,7 @@ waitForD3().then(() => {
function reset() {
cancelAnimationFrame(animationFrame);
isSimulating = false;
numPeers = 30;
numPeers = 3;
averagePathLengths = [
{
numPeers: 0,
Expand Down

0 comments on commit a38c0a1

Please sign in to comment.