feat(graph): centrality + cluster analytics (corpus graph PR B) #129

Merged
chaim merged 1 commits from worktree-graph-analytics into main 2026-06-07 21:05:14 +00:00
Owner

PR B מתוך 4. ה-Graph Analysis של Obsidian — חושף השפעה ומבנה מעבר לספירת ציטוטים גולמית.

Backend (מודול חדש web/graph_metrics.py — pure, ללא תלות, ללא DB → G2):

  • PageRank (power-iteration), betweenness (Brandes), community (label-propagation דטרמיניסטי + fallback ל-connected-components), מחושב in-memory על תת-גרף הציטוטים ש-build_corpus_graph כבר שלף. נורמליזציה 0–1; community ממוספר לפי גודל (צבעים יציבים).
  • GraphNode += pagerank/betweenness/community (None אלא אם metrics=true).
  • build_corpus_graph + endpoint += metrics=false (מסלול ברירת-מחדל ללא שינוי). אומת על הקורפוס החי: 147 נקודות ב-13ms.

Frontend:

  • graph-canvas: color-by (סוג / תחום / דרגת-סמכות / אשכול / עדכניות) ו-size-by (ציטוטים / PageRank / Betweenness).
  • graph-view: בקרות + מטריקות מבוקשות רק כשצריך + overlay של מטריקות גלובליות על נקודות ה-neighborhood לפי id (PageRank של נקודה לא משתנה כשמתמקדים) + פאנל דירוג (Tabs: המשפיעות / גשרים, לחיצה→focus) + מקרא דינמי.
  • graph-filter-panel: Selects "צביעה לפי" + "גודל נקודה לפי".

build+lint עוברים. Invariants: G2 (מטריקות pure, אפס כתיבות) · UI2. api:types אחרי deploy.

🤖 Generated with Claude Code

PR B מתוך 4. ה-Graph Analysis של Obsidian — חושף **השפעה ומבנה** מעבר לספירת ציטוטים גולמית. **Backend (מודול חדש `web/graph_metrics.py` — pure, ללא תלות, ללא DB → G2):** - **PageRank** (power-iteration), **betweenness** (Brandes), **community** (label-propagation דטרמיניסטי + fallback ל-connected-components), מחושב in-memory על תת-גרף הציטוטים ש-`build_corpus_graph` כבר שלף. נורמליזציה 0–1; community ממוספר לפי גודל (צבעים יציבים). - `GraphNode` += `pagerank/betweenness/community` (`None` אלא אם `metrics=true`). - `build_corpus_graph` + endpoint += `metrics=false` (מסלול ברירת-מחדל ללא שינוי). **אומת על הקורפוס החי: 147 נקודות ב-13ms.** **Frontend:** - `graph-canvas`: **color-by** (סוג / תחום / דרגת-סמכות / **אשכול** / עדכניות) ו-**size-by** (ציטוטים / **PageRank** / **Betweenness**). - `graph-view`: בקרות + מטריקות מבוקשות רק כשצריך + overlay של מטריקות גלובליות על נקודות ה-neighborhood לפי id (PageRank של נקודה לא משתנה כשמתמקדים) + **פאנל דירוג** (Tabs: המשפיעות / גשרים, לחיצה→focus) + מקרא דינמי. - `graph-filter-panel`: Selects "צביעה לפי" + "גודל נקודה לפי". build+lint עוברים. Invariants: G2 (מטריקות pure, אפס כתיבות) · UI2. `api:types` אחרי deploy. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-07 21:05:08 +00:00
The Obsidian "Graph Analysis" equivalent — surfaces influence and structure
beyond raw citation count.

Backend (new web/graph_metrics.py — pure, dependency-free, no DB → G2):
- PageRank (power-iteration), betweenness (Brandes), community (deterministic
  label-propagation + connected-components fallback), computed in-memory over
  the precedent citation subgraph that build_corpus_graph already fetched.
  Normalized 0–1; community ints dense-ranked by size (stable colours).
- GraphNode += pagerank/betweenness/community (None unless metrics=true).
- build_corpus_graph + /api/graph/corpus gain metrics=false (default path
  unchanged). Validated on the live corpus: 147 nodes in 13ms.

Frontend:
- graph.ts: GraphNode metrics fields + metrics param.
- graph-canvas: color-by (type | practice_area | precedent_level | community |
  recency) and size-by (in-degree | pagerank | betweenness) via colorForNode /
  radiusForNode; exported palettes.
- graph-view: colorBy/sizeBy controls; metrics requested only when needed;
  global metrics overlaid onto neighborhood nodes by id (a node's PageRank
  shouldn't change when focused); a ranking panel (Tabs: המשפיעות / גשרים,
  click → focus); dynamic legend per color-by.
- graph-filter-panel: "צביעה לפי" + "גודל נקודה לפי" Selects.

web-ui build + lint pass. Invariants: G2 (metrics pure, no DB writes),
UI2 (model grows on explicit Pydantic). api:types post-deploy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit ecd9e46bb9 into main 2026-06-07 21:05:14 +00:00
chaim deleted branch worktree-graph-analytics 2026-06-07 21:05:14 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#129