← All tests

Cytoscape.js — note-link graph

Second Brain note-link graph from a real Markdown notes folder

2026-11-20FINDS - TESTS

Try it

Demo — index.html · Demo — app.js · Demo — graph.json

Report

FINDS - TESTS slate 2, test 4 — Cytoscape.js as a Second Brain note-link graph view

Date: 2026-11-20 · Subject: Cytoscape.js 3.35.0 (+ cytoscape-fcose 2.2.0) as an embeddable graph VIEW over plain Markdown notes.

Corpus choice

Chosen: Ros's relationship memory — ~/memory/people/ (200 notes) + ~/memory/groups/ (2 notes) + ~/MEMORY.md as a hub note = 203 notes. It is the only candidate that is both a genuine Markdown corpus and genuinely cross-referenced at scale:

  • Blog (~/workspace/blog/): only 9 Markdown files — too small to judge a graph renderer.
  • Finds records (~/workspace/finds-library-records/): only 3 Markdown files; the Finds Library's cross-references live in its app database, not in Markdown notes — it fails the premise of the test (a view over plain files).
  • Relationship memory: 200+ notes whose pages constantly reference each other — by name, in prose. Caveat: this corpus has no wikilinks and almost no Markdown links (exactly 2 in the whole corpus). Its link layer is textual, which is precisely what a Second Brain view over existing plain files would face.

Link-extraction rules (as used by extract.py)

  • A. Name mention — another note's display_name (frontmatter; fallback H1, then filename) appears in this note's body (frontmatter stripped), word-boundary, case-sensitive, names ≥ 3 chars. This one rule produces the graph: every extracted edge rests on it.
  • B. Relative Markdown link — ](….md) resolving inside the corpus. Only 2 exist (Sausalito Nursery School parents → Veronica Maier, → Catherine Moniz); both are also name mentions, so B added confirmation, not edges.
  • C. Hub citation — a body containing the literal MEMORY.md cites the hub (77 notes do). Mechanically a special case of A (the hub's name is its filename), recorded separately because its meaning differs: most are provenance citations ("this fact came from MEMORY.md"), not topical links. The hub's own 36 outgoing edges are rule-A mentions in MEMORY.md itself.

Known precision limits, disclosed: name mentions are a proxy — a mention is a reference, not always a relationship. One of 201 edges is a clear false-positive class member (Lukas Havlik → Lukas, fired by his own full name containing the word "Lukas"). Family cross-mentions in the same class (Misha Chuba → Genia Chuba) were hand-checked and are genuine.

Reconciliation

Claim Count Source
People notes on disk (excl. INDEX.md) 200 ls ~/memory/people/
Group notes on disk (excl. INDEX.md) 2 ls ~/memory/groups/
Hub note 1 ~/MEMORY.md
Nodes in graph.json 203 extract.py
Edges in graph.json 201 extract.py
Edges touching the hub 113 (77 in / 36 out) degree of MEMORY.md node
Topical note↔note edges 88 201 − 113
Notes with ≥ 1 edge 123
Isolated notes 80
DOM nodes / edges in the running page 203 / 201 — exact match verify.mjs (cy.nodes().length)
10-edge verification sample 10 / 10 confirmed in source text reconciliation.json + manual re-grep

Top-degree notes after the hub: Squat University 11, Jesse Rurka 9, Lukas 8, Roye Gold 8, Vinh Giang 8.

What was built (the pipeline is the deliverable)

extract.py (corpus → graph.json + reconciliation.json) → app.js (Cytoscape + fcose) → build.mjs (esbuild; produces one self-contained index.html, 1.6 MB with library and data inlined; no build step needed to view it).

Page features, all exercised headlessly: nodes sized by degree, coloured by kind (person / group / amber diamond hub); click a node → side panel with title, kind, degree, closeness rank, summary, text snippet, and clickable out-/in-neighbour lists, with the rest of the graph faded; search box that finds a note by name, centres it and marks it ("Kirn" → Kirn Gill, panel correct); layout switcher (fCoSE force / concentric-by-degree); counts header generated from the data (203 notes · 201 links · 80 unlinked).

Verification evidence (verify.mjs, verify-log.txt)

  • DOM counts equal graph.json exactly (203 / 201), before and after a layout switch.
  • Layout settle: fCoSE ran unanimated; max node drift over 1.5 s = 0.00 px — the layout is static once computed, no endless jiggle.
  • Selection, panel contents, and search all asserted in the run (Lukas: degree 8, rank 1, 8 in-neighbours listed; Kirn Gill found by search).
  • Screenshots at 1600×900: screenshot-full.png, screenshot-selected.png, plus screenshot-concentric.png (extra).
  • Environment caveat: the brief's chromium-1208 binary could not be used — its renderer crashes on any Cytoscape canvas redraw in this VM (reproduced with a minimal 203-node page, with and without swiftshader flags; probes deleted after diagnosis). Chromium-1254 and both headless shells run the same page cleanly, so verification used chromium-1254. This is a VM/browser-build quirk, not a Cytoscape defect — but it is a reminder that "renders in headless CI" is browser-build-sensitive for canvas-heavy libraries. The only console error in the passing run was a favicon 404.

Legibility verdict — honest

  • At overview, the graph tells the truth about this corpus in one glance: it is a hub-and-spoke memory, not a web. One giant hub (degree 113), a topical cluster of ~120 notes around it, a few satellite pairs, and 80 unlinked notes. You could not see that shape from the folder listing; the graph view earns its keep on that alone.
  • The connected core is readable at 1600×900 — most labels legible, clusters (family, school parents, influencer/creator circle) distinguishable — but the hub's inner ring is crowded and some labels collide. It is a map you navigate (search, click, fade), not one you read like a poster.
  • The isolates are the ugly part: fCoSE parks the 80 unlinked notes in a dense slab whose labels overlap into near-illegibility. A production view needs an isolates policy (dock them in a list, or a "linked only" toggle) — the renderer gives you the data to do it (degree is right there), but no layout makes 80 unconnected labelled dots beautiful.
  • Concentric-by-degree disappoints on this degree distribution: with degrees spanning 0–113, rings spread so wide the view degenerates (see screenshot). The switcher works; the layout is wrong for hub-heavy graphs without log-bucketing. fCoSE is the working default.
  • What breaks first at Second Brain scale (hundreds → thousands of notes): labels, not rendering. Cytoscape's canvas handles thousands of nodes; fCoSE stays fast enough. What dies is (1) label legibility — you must switch to label-on-hover/selected-only, (2) force-layout meaning — past ~1–2k notes a hairball conveys only "there is a hub", and (3) the extraction layer — name-mention precision falls as names collide (more Lukas/Lukas Havlik cases, common-word names). The scalable pattern is the one this page already prototypes: full graph for shape, search + neighbourhood focus for reading. A Second Brain graph view should open on the neighbourhood, not the universe.

vs React Flow (slate 2, test 1)

Different territories, no real contest. React Flow won the Muse Map test's operational half: it is a node-editor library — trees and DAGs with ports, custom node UIs, and editing interactions; for a fixed hierarchy (org chart, routing view) its model is the right shape and its React integration is native. Cytoscape is a network-analysis library: arbitrary cyclic graphs, a deep layout zoo (fcose/cose/concentric/…), graph algorithms (neighbourhoods, paths, centrality) built in, framework-agnostic, and it renders to canvas without a DOM node per element — which is why 203 nodes is nothing to it and 10k is plausible. Rule of thumb from the two tests: tree you edit → React Flow; network you explore → Cytoscape. The Second Brain note graph is the second kind.

Effort log

Corpus inspection + extraction rules ~25 min; extraction + reconciliation + 10-edge hand check ~20 min; page + build ~25 min; browser-crash diagnosis (1208) ~35 min (three probe rounds); final verification + screenshots ~10 min; report ~15 min. Total ≈ 2 h 10 min, of which the browser quirk was the single biggest sink — the Cytoscape work itself was uneventful.

Draft verdict + test-record block

  • Subject: Cytoscape.js 3.35.0 (+ cytoscape-fcose 2.2.0) — graph view layer for plain-Markdown note corpora.
  • What ran: full pipeline on Ros's real relationship-memory corpus (203 notes): scripted extraction with stated rules → graph JSON → single-file interactive page (degree sizing, click panel with neighbours + snippet, name search, fcose/concentric switcher) → headless verification (counts, settle, interactions, screenshots).
  • When: 2026-11-20.
  • Outcome: works end-to-end on real data; counts reconcile exactly; the view truthfully exposes the corpus's hub-and-spoke shape. Weak points are corpus-shaped (80 isolates slab, hub crowding, mention-precision), not library defects; concentric layout is a poor fit for hub-heavy degree distributions. Environment note: chromium-1208 renderer crashes on Cytoscape redraws in this VM; 1254 fine.
  • Output reference: ~/workspace/finds-tests/cytoscape-notes-2026-11-20/ — index.html (the page), graph.json, extract.py, reconciliation.json, verify-log.txt, screenshot-full.png, screenshot-selected.png, screenshot-concentric.png, this report.
  • Reuse proposal: Reuse later — scoped: the designated graph-view layer if the Second Brain lands on plain Markdown files Ros owns (the Lorem-style data layer), to be wired behind the note app, not instead of it. Not Adopt yet: the Second Brain module/data decision is still open (slate 3.6 tests the apps), and a graph view is an accessory to that decision, not a driver. If the data layer goes database/app-native instead, this drops to Skip — the extraction rules, not the renderer, are the reusable asset in that world.