Welcome to lightgraph’s documentation!#
lightgraph is a high-performance HTML canvas-based network visualization tool for the browser, Jupyter notebooks (Python), and R. It keeps thousands of nodes and edges interactive through batched canvas rendering, viewport culling, and high-DPI-aware drawing.
Try it live — the OpenFlights route network, 3,257 airports and 18,930 routes, colored by continent. Drag to pan, scroll to zoom, hover an airport to light up its neighborhood, and double-click a hub to isolate its ego network (Escape restores):
Note
This project is still work in progress. The API is not stable and is subject to change.
Features#
High Performance: batched HTML5 Canvas rendering with viewport culling keeps graphs with thousands of nodes and edges smooth — see the benchmarks
Modeless Interaction: pan, zoom, select, box-select, and drag nodes without switching tools
Graph Exploration: neighbor highlighting on hover and double-click ego-network filtering
Weighted Edges: map edge weights to width and opacity
Groups & Communities: colored groups with optional ellipses; both bindings can auto-detect communities (
node_groups='auto')Metric-Driven Styling: map node metrics to size or color
Built-in Analytics: degree, betweenness, closeness, eigenvector, PageRank, communities, components, and k-hop neighborhoods in both Python (
lightgraph.analytics) and R (lg_*functions)Sharp Everywhere: follows the display’s devicePixelRatio and exports high-resolution PNGs
Jupyter & R Integration: one-call APIs in Python and R built on the same JavaScript runtime
Quick Start#
Installation#
For Python binding, you can install from PyPI:
pip install lightgraph
Basic Usage#
from lightgraph import net_vis, datasets, pagerank
edges = datasets.got() # bundled: A Storm of Swords character network
net_vis(edges=edges, node_groups='auto', # auto-detect communities
node_metric=pagerank(edges), # size nodes by PageRank
edge_weight_to_width=True)
Or the same in R:
library(lightgraph)
data(got)
lightgraph(edges = got, node_groups = "auto",
node_metric = lg_pagerank(got),
edge_weight_to_width = TRUE)