Using Linnet from Python
Symbolica Community exposes native Linnet graphs as symbolica.community.graph. Build and install the complete Community wheel, or run these commands from the repository root to install its locked notebook host. Retain .venv/.nix-python/symbolica while using the Nix-built host: its native libraries remain in the Nix store.
python -m venv .venv
nix develop -c just python-develop community --python .venv/bin/python
. .venv/bin/activateGraph rendering uses native Rust geometry and direct MathML labels. Notebook display requires anywidget; the live browser measures labels before the drawing is finalized. No Typst compiler is used for this path.
The GammaLoop package and this checkout’s isolated notebook host declare notebook-display (anywidget>=0.9,<1), graph-export (playwright>=1.55,<2) and typst-export (typst>=0.15) extras. Do not assume those extras exist in the currently released external Community wheel. For an existing host environment, install the dependencies you need directly:
python -m pip install "anywidget>=0.9,<1"Parse and inspect a graph
Save this as linnet_quickstart.py:
from symbolica.community import graph as lp
codec = lp.DotCodec.topology()
graph = lp.Graph.from_dot(
"""
digraph G {
A;
B;
A -> B;
}
""",
codec,
)
whole = graph.full_subgraph()
assert graph.n_nodes == 2
assert graph.n_edges == 1
assert len(graph.nodes_of(whole)) == 2
assert len(graph.edges_of(whole)) == 1
print(graph.to_dot())Run python linnet_quickstart.py. Success means the assertions pass and the graph is printed as DOT. Graph also exposes typed nodes, half-edges, subgraphs, cycles, oriented cuts, and traversal trees; use the Python reference for the exact current surface.
In a notebook, keep and display the configured view:
from IPython.display import display
view = graph.render()
display(view)After the browser finishes measuring, snapshot = view.measured() returns an immutable drawing. snapshot.to_svg(), snapshot.to_html() and snapshot.save("graph.svg") preserve its measured boxes and embedded font. measured() raises while labels are pending.
Default view.snapshot(), view.to_svg() and view.to_html() export complete static output without launching a browser. They reuse completed measurements, otherwise use optional typst-py outlining when available, otherwise estimated STIX MathML label bounds. Estimates leave measurement pending. Installing anywidget adds live notebook measurement; earlier snapshots remain immutable.
Scripts may explicitly request view.measured(browser="chromium"). Install playwright>=1.55,<2 and run python -m playwright install chromium first. The default SVG contains browser MathML in XHTML foreignObject elements; use view.outlined() with optional Python typst-py (distribution typst>=0.15) for vector labels before PDF, PNG or Typst SVG import. Strict measured() never uses estimates or launches a browser implicitly.
Continue with Rendering graphs from Python to explore a complete graph with custom drawing selectors. The live Python playground also lets you edit DOT and tune the layout while watching the solver run.
Use the Rust guide when you need Linnet’s complete crate API, or the Typst guide when the final result should be a drawing.