oneshotlm
Compare all models on this prompt →

Force-directed graph · deepseek-v4-pro

Using the pre-provided d3.min.js (global d3), render an interactive force-directed graph of about 40 nodes in several clusters with draggable nodes, hover highlighting of neighbors, and zoom/pan. Define the sample nodes and links inline.

⛨ sandboxed Open in new tab ↗
transcript · 8 messages
user

Using the pre-provided d3.min.js (global d3), render an interactive force-directed graph of about 40 nodes in several clusters with draggable nodes, hover highlighting of neighbors, and zoom/pan. Define the sample nodes and links inline.

assistant
thinking
The user wants me to create a single-page interactive force-directed graph using d3.js. Let me plan this out:

1. Check that d3.min.js exists in the current directory
2. Create index.html with:
   - Inline CSS in a <style> tag
   - Load d3.min.js via <script src="d3.min.js">
   - Inline JS that creates a force-directed graph with ~40 nodes in clusters
   - Draggable nodes
   - Hover highlighting of neighbors
   - Zoom/pan

Let me first check if d3.min.js exists.
bash {"command":"ls -la d3.min.js"}
toolResult

-rw-r--r-- 1 node node 279706 Jul 8 00:38 d3.min.js

assistant
thinking
Good, d3.min.js exists. Now let me create the index.html file with all the requirements:

- ~40 nodes in several clusters
- Force-directed layout
- Draggable nodes
- Hover highlighting of neighbors
- Zoom/pan
- All inline (CSS in <style>, JS in <script>)
- Uses d3.min.js from local file

I'll create about 40 nodes across 4-5 clusters. Each cluster will have a central hub node and several satellite nodes connected to it, plus some inter-cluster links.

Let me design the data:
- Cluster 1: "Tech" - 10 nodes
- Cluster 2: "Science" - 8 nodes
- Cluster 3: "Arts" - 8 nodes
- Cluster 4: "Business" - 8 nodes
- Cluster 5: "Sports" - 6 nodes

That's 40 nodes total.

I'll create the node and link data inline, then build the force simulation with:
- forceLink for links
- forceManyBody for repulsion
- forceCenter to center the graph
- forceCollide to prevent overlap

Features:
- Drag behavior on nodes
- Hover: highlight the hovered node and its neighbors, fade everything else
- Zoom/pan with d3.zoom()

Let me write this out.
write /workspace/index.html (9142 bytes)
toolResult

Successfully wrote 9142 bytes to /workspace/index.html

assistant
thinking
The file is written. Let me verify it's all there and correct.
bash {"command":"wc -l /workspace/index.html && head -5 /workspace/index.html && echo \"---\" && tail -5 /workspace/index.html"}
toolResult

370 /workspace/index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> --- simulation.alpha(0.1).restart(); }); </script> </body> </html>

assistant
thinking
The file looks good. Let me summarize what was built.

Done. Here's what `index.html` contains: **Graph structure** — 40 nodes across 5 clusters: - **Tech** (blue) — 10 nodes: React, Vue, Angular, Svelte, Node.js, TypeScript, Rust, Python, GraphQL, Docker - **Science** (green) — 8 nodes: Physics, Chemistry, Biology, Astronomy, Geology, Genetics, Neuroscience, Ecology - **Arts** (purple) — 8 nodes: Painting, Sculpture, Music, Theater, Dance, Literature, Cinema, Photography - **Business** (orange) — 8 nodes: Finance, Marketing, Sales, Strategy, Operations, HR, Analytics, Legal - **Sports** (red) — 6 nodes: Soccer, Basketball, Tennis, Swimming, Cycling, Climbing **Links** — each cluster has its first node as a hub connected to all others, plus a chain across remaining nodes for extra intra-cluster density, plus 13 inter-cluster bridge links connecting different domains. **Interactions:** - **Drag** — grab any node to move it; the simulation reheats on drag start and releases on drag end - **Hover** — highlights the hovered node in white, all its neighbors and their connecting links in blue, fading everything else to near-transparency. A tooltip at the bottom shows name, cluster, and neighbor count - **Zoom/pan** — scroll to zoom, drag background to pan (scale range 0.15×–4×) - **Cluster centering** — a custom force gently pulls each cluster toward its own radial position around the center, so clusters stay visually separated - **Responsive** — recalculates center and viewport on window resize All CSS and JS are inline; only `d3.min.js` is loaded from the local file. No network requests.

TAKE IT TO CODE

A single self-contained HTML file — copy it and open in any browser, or reuse the prompt with your own pi-agent run.

RUN

modeldeepseek-v4-pro
vendorDeepSeek
harnesspi-agent
generated2026-07-08

EVALUATION

4/5 working

Force-directed graph with clusters, physics settling animation, working drag and zoom/pan; keyboard inputs had no effect (expected).

Vision grade · anthropic/claude-sonnet-5

MEASUREMENTS

Raw readings from the capture, not a verdict — the grade above is the only judgement. Percentages are how much of the screen changed; the measure under-reports sparse motion on a dark background.

idle motion5.3%
on click0.4%
on drag4.3%
on wheel3.3%
on enter + space0.0%
on arrow keys0.0%
on w/a/s/d0.0%
frame spread10.1 / 255
console errors0
js errors none

METRICS

runtime64.2s
tokens in5.0k
tokens out3.9k
cached9.0k
cost / run$0.0056