This repository contains documentation on the PCG design and implementation. It is intended to be the authoritative source on information about the PCG. However, because much of the documentation is still incomplete or outdated, the paper describing the PCG is probably a better resource currently: https://arxiv.org/pdf/2503.21691.
Live documentation: https://viperproject.github.io/pcg-docs
- Node.js (>= 14.0.0) - Install from nodejs.org
- Rust (for mdbook) - Install from rust-lang.org
First-time setup installs all dependencies including mdbook and mdbook-katex:
make setupThis command will:
- Install dependencies (Cytoscape.js, webpack, etc.)
- Install mdbook and mdbook-katex via cargo
Start the development server with automatic reload on changes:
make serveThis will:
- Build the JavaScript bundle
- Start watching for JavaScript changes
- Start mdbook server at http://localhost:3000
- Automatically rebuild on any source file changes
Build the static site for deployment:
make buildThis creates the production-ready site in the book/ directory.
| Command | Description |
|---|---|
make setup |
One-time setup: installs all dependencies |
make serve |
Start development server with auto-reload |
make build |
Build production site |
make clean |
Remove generated files and dependencies |
make help |
Show available commands |
This documentation includes a custom mdbook preprocessor for rendering hypergraphs. Hypergraphs can be included in markdown files using either JSON or YAML format:
```hypergraph
{
"height": "500px",
"nodes": [
{"id": "lp1", "place": "x", "lifetime": "'a", "x": 100, "y": 100},
{"id": "p1", "place": "y", "x": 200, "y": 200},
{"id": "p2", "place": "z", "x": 300, "y": 150}
],
"edges": [
{"sources": ["lp1"], "targets": ["p1"], "label": "simple edge"},
{"sources": ["lp1", "p1"], "targets": ["p2"], "label": "hyperedge"}
]
}
``````hypergraph-yaml
height: 500px
nodes:
- id: lp1
place: x
lifetime: "'a"
x: 100
y: 100
- id: p1
place: y
x: 200
y: 200
- id: p2
place: z
x: 300
y: 150
edges:
- sources: [lp1]
targets: [p1]
label: simple edge
- sources: [lp1, p1]
targets: [p2]
label: hyperedge
```height(optional): Controls the height of the rendered graph (default: "400px")
Nodes in hypergraphs can be one of two types based on their fields:
-
Lifetime Projection Nodes: Have both
placeandlifetimefields- Displayed with hexagonal shape
- Label format:
place ↓ lifetime - Color: Purple (#673AB7)
-
Place Nodes: Have only
placefield (nolifetime)- Displayed with rounded rectangle shape
- Label format:
place - Color: Orange (#FF9800)
All nodes require:
id: Unique identifier for the nodex,y: Position coordinates- Either
placealone (for place nodes) or bothplaceandlifetime(for lifetime projection nodes)
All edges in the hypergraph are represented uniformly with:
sources: Array of source node IDstargets: Array of target node IDslabel(optional): Edge label text
Edges are automatically styled as hyperedges when they have multiple sources or targets.
Hyperedges (edges with multiple sources or targets) are visualized using the cytoscape-bubblesets library:
- Individual edges are drawn between all source-target pairs with dotted lines
- A colored bubble overlay groups all nodes participating in the hyperedge
- Each hyperedge gets a unique color for its bubble
- Bubbles can overlap, allowing nodes to belong to multiple hyperedges
The documentation is automatically built and deployed to GitHub Pages when changes are pushed to the main branch.
The documentation system consists of:
- mdbook: Static site generator for the main documentation
- mdbook-katex: LaTeX math rendering support
- Custom preprocessor: Converts hypergraph code blocks to interactive visualizations
- Cytoscape.js: Graph visualization library
- cytoscape-bubblesets: Plugin for visualizing hyperedges as bubble overlays
- Webpack: Bundles JavaScript dependencies into a single file
- Preprocessing: The hypergraph preprocessor (
preprocessors/hypergraph.js) converts graph definitions in markdown to HTML containers - JavaScript bundling: Webpack bundles the renderer and dependencies into
theme/hypergraph.js - Site generation: mdbook processes markdown files and generates the static HTML site
- Runtime rendering: The bundled JavaScript renders interactive graphs in the browser
pcg-docs/
├── src/ # Markdown source files
├── src-js/ # JavaScript source for hypergraph renderer
├── preprocessors/ # mdbook preprocessors
├── theme/ # CSS and bundled JavaScript
├── scripts/ # Build and setup scripts
├── book/ # Generated static site (not stored in version control)
└── webpack.config.js # Webpack bundling configuration