## `genesis/graph.py` from __future__ import annotations import os, html from typing import List # Lightweight graph preview from citations (no DB required). If Neo4j is configured, you can extend here. def build_preview_graph_html(citations: List[dict]) -> str: # Simple HTML graph: papers as nodes, edges from a central topic node if not citations: return "

No citations to graph.

" nodes = [] edges = [] nodes.append({"id": "topic", "label": "Topic", "color": "#0ea5e9"}) for i, c in enumerate(citations): nid = f"p{i}" label = (c.get("title") or "citation").strip()[:80] url = html.escape(c.get("url", "")) nodes.append({"id": nid, "label": label, "url": url}) edges.append({"from": "topic", "to": nid}) # Minimal vis.js rendering return f"""
""".replace("{nodes}", str(nodes)).replace("{edges}", str(edges))