Skip to main content

scivianna-graph

Build interactive ReactFlow graphs from a plain-Python model. Each node is an embedded Panel/Bokeh figure on a draggable, zoomable canvas - ideal for visualizing the topology of coupled simulations or 1D pipe networks where the plots need to be rotated, plugged on any side and rearranged by hand.

from scivianna_graph import GraphModel, GraphNode, GraphEdge, SciviannaGraph

model = GraphModel()
model.add_node(GraphNode(id="core", position=(0, 0), label="Core", rotation=15))
model.add_node(GraphNode(id="assembly", position=(420, 0), label="Assembly"))
model.add_edge(
    GraphEdge(source="core", target="assembly",
              source_direction="right", target_direction="left")
)

SciviannaGraph(model).make_panel().servable()

Features

  • Plugs on every side - each node exposes handles on all four sides (top/bottom/left/right). An edge declares which side it attaches to on each endpoint, and directions are expressed in the node's own frame, so a pipe flows right-out -> left-in whatever its rotation.
  • Rotatable nodes - rotate any node (border, handles and figure together) by an angle in degrees. An optional fixed pivot (rotation_origin) keeps a point in place while the node rotates - e.g. rotate a pipe about its inlet so pipes fan out radially.
  • Group drag-select - drag an empty area of the canvas to marquee-select several nodes and move them together; drag a single node to reposition it.
  • Embedded figures - each node renders any Panel viewable (typically a Bokeh figure). Give the viewable explicit width/height so the node is sized correctly.
  • Zoom, pan, minimap, controls - standard ReactFlow navigation, all optional.

Install

pip install scivianna-graph

The frontend bundle ships with the package, so no build step or network access is needed at runtime.

Usage

GraphModel is plain Python (no frontend required) and can be built, inspected and serialized on its own:

from scivianna_graph import GraphModel, GraphNode, GraphEdge

model = GraphModel()
model.add_node(GraphNode(id="a", position=(0, 0), label="Inlet",
                         view=bokeh_pane_a))          # optional embedded figure
model.add_node(GraphNode(id="b", position=(300, 0), label="Core",
                         rotation=90,                  # rotate about the centre ...
                         data={"rotation_origin": (0.5, 1.0)}))  # ... or about a pivot
model.add_edge(GraphEdge(source="a", target="b",
                         source_direction="right", target_direction="left"))

graph = SciviannaGraph(model)
graph.make_panel().servable()

Nodes may carry an embedded Panel viewable (e.g. a Bokeh figure wrapped in pn.pane.Bokeh) via GraphNode(view=...).

Display options are passed as SciviannaGraph(...) kwargs: min_zoom, max_zoom, show_controls, show_minimap, enable_multiselect, show_unconnected_ports (default false: only plugs used by an edge are drawn) and rotation_origin (default pivot for every node).

API

Name Purpose
GraphModel Container of nodes and edges; add_node, add_edge, get_node, validate, to_dict.
GraphNode A node: id, position, optional label, view, rotation, data.
GraphEdge A directed edge: source, target, source_direction, target_direction, optional label.
SciviannaGraph Builds the canvas from a GraphModel; set_model, make_panel, and in-place set_node_* / set_edge_* helpers.

Development

The frontend is a standalone React app (src/scivianna_graph/dist/app.jsx) compiled to SciviannaGraphCanvas.bundle.js (+ .bundle.css). To rebuild it after editing the JSX, run from the repository root:

./build.sh            # or: npm run build

build.sh runs npm install (local esbuild) and then panel compile. It needs node, npm, network access for the first run, and pip install panel. Rebuild after every change to app.jsx. Without a bundle, Panel compiles the JSX in the browser and fetches @xyflow/react from esm.sh (needs network). See AGENTS.md for build notes and gotchas.

Metadata

Release files for scivianna-graph 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scivianna-graph 0.1.0
File Size Uploaded Provenance Actions
scivianna_graph-0.1.0.tar.gz 131.7 kB Without provenance Details for scivianna_graph-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for scivianna-graph 0.1.0
File Interpreter ABI Platform Actions
scivianna_graph-0.1.0-py3-none-any.whl Python 3 none any Details for scivianna_graph-0.1.0-py3-none-any.whl

Total release size: 264.7 kB

Release files / scivianna_graph-0.1.0.tar.gz

Download URL scivianna_graph-0.1.0.tar.gz
Size 131.7 kB
Tags Source
SHA-256 checksum
How to use checksums
64d0aecf94410dbd61fea5e408686c9d33d552aadb9f8268142063d560f8836e
BLAKE2b-256 checksum
How to use checksums
db05638efe09a7b43f4c10b12e68f018d680a52df5ac9f8eb823c32632e8eb6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / scivianna_graph-0.1.0-py3-none-any.whl

Download URL scivianna_graph-0.1.0-py3-none-any.whl
Size 133.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a1cef1112851fa7c204904f9771f2e364e67c81eb2e035f2f5ce35be4a9a412
BLAKE2b-256 checksum
How to use checksums
6bee0216cc1535c95a1c5fbc6399114a8bc6a6dbe882b177eaf6d336e0d30b46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for scivianna-graph 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page