Module

analysis.graph_visualizer

Graph Visualization Generator for Bengal SSG.

Generates interactive D3.js visualizations of the site's knowledge graph. Inspired by Obsidian's graph view.

Classes

GraphNode dataclass
Node in the graph visualization.
0

Node in the graph visualization.

Attributes

Name Type Description
id str

Unique identifier for the node

label str

Display label (page title)

url str

URL to the page

type str

Page type (page, index, generated, etc.)

tags list[str]

List of tags

incoming_refs int

Number of incoming references

outgoing_refs int

Number of outgoing references

connectivity int

Total connectivity score

size int

Visual size (based on connectivity)

color str

Node color (based on type or connectivity)

GraphEdge dataclass
Edge in the graph visualization.
0

Edge in the graph visualization.

Attributes

Name Type Description
source str

Source node ID

target str

Target node ID

weight int

Edge weight (link strength)

GraphVisualizer
Generate interactive D3.js visualizations of knowledge graphs. Creates standalone HTML files with:…
5

Generate interactive D3.js visualizations of knowledge graphs.

Creates standalone HTML files with:

  • Force-directed graph layout
  • Interactive node exploration
  • Search and filtering
  • Responsive design
  • Customizable styling

Methods 2

generate_graph_data
Generate D3.js-compatible graph data.
0 dict[str, Any]
def generate_graph_data(self) -> dict[str, Any]

Generate D3.js-compatible graph data.

Returns

dict[str, Any]

Dictionary with 'nodes' and 'edges' arrays

generate_html
Generate complete standalone HTML visualization.
1 str
def generate_html(self, title: str | None = None) -> str

Generate complete standalone HTML visualization.

Parameters 1
title str | None

Page title (defaults to site title)

Returns

str

Complete HTML document as string

Internal Methods 3
__init__
Initialize graph visualizer.
2 None
def __init__(self, site: Site, graph: KnowledgeGraph)

Initialize graph visualizer.

Parameters 2
site Site

Site instance

graph KnowledgeGraph

Built KnowledgeGraph instance

_get_page_id
Get a stable ID for a page (using source_path hash).
1 str
def _get_page_id(self, page: Any) -> str

Get a stable ID for a page (using source_path hash).

Parameters 1
page Any

Page object

Returns

str

String ID for the page

_get_node_color
Determine node color based on page properties. Returns CSS variable name that …
2 str
def _get_node_color(self, page: Any, connectivity: Any) -> str

Determine node color based on page properties.

Returns CSS variable name that will be resolved in JavaScript. JavaScript will read the computed value from CSS custom properties.

Parameters 2
page Any

Page object

connectivity Any

PageConnectivity object

Returns

str

CSS variable name (e.g., "var(--graph-node-hub)")