Garphield for Python
The garphield package moves a graph into an interactive notebook view and
returns the edited project or NetworkX graph to the same Python session.
Garphield supports Python 3.10 through 3.14.
Install
Section titled “Install”pip install 'garphield[networkx]'Use 'garphield[tables]' for pandas without NetworkX, or install both extras.
From NetworkX
Section titled “From NetworkX”import garphield as gphimport networkx as nx
graph = nx.karate_club_graph()view = gph.show( graph, node_color="club", node_size=graph.degree, node_label=str,)show() displays the graph and returns a synchronous GraphView. Move between
the notebook view and ordinary Python without a separate event loop:
view.select([0, 1, 2]).fit()view.bind("node_color", gph.algorithm("louvain", resolution=1.1))
edited_graph = view.to_networkx()edited_project = view.to_project()Bindings accept familiar Python values:
| Python value | Example | Use |
|---|---|---|
| Attribute name | node_color="club" |
Bind an existing attribute. |
| Mapping or view | node_size=graph.degree |
Match values by node identity. |
| Iterable | node_size=centrality.values() |
Assign in graph iteration order. |
| Set | node_color=important |
Encode membership. |
| Partition | node_color=[group_a, group_b] |
Encode categories. |
| Callable | node_label=lambda node: str(node) |
Compute a value. |
| Garphield algorithm | gph.algorithm("louvain") |
Compute inside the view. |
Pass positions and an initial layout directly:
view = gph.show(graph, pos=nx.spring_layout(graph), layout="force")From pandas
Section titled “From pandas”An edge table is enough:
import pandas as pdimport garphield as gph
edges = pd.DataFrame( { "source": ["ada", "ada", "grace"], "target": ["grace", "alan", "alan"], "weight": [1.5, 0.5, 2.0], })
view = gph.show(edges)tables = view.to_project().to_pandas()Pass a node table when you have node attributes:
project = gph.Project.from_pandas( edges, nodes, source="from_id", target="to_id", node_id="person_id",)Round-trip guarantees
Section titled “Round-trip guarantees”The adapters preserve direction, multigraph state, edge keys, attributes, and
typed identities. Values such as True, 1, 1.0, and "1" remain distinct.
The adapter escapes reserved attribute names in the project manifest and
restores them on the way back.
multi = nx.MultiDiGraph()multi.add_edge("ada", "grace", key="mentor", weight=1.5)
restored = gph.Project.from_networkx(multi).to_networkx()assert restored.edges["ada", "grace", "mentor"]["weight"] == 1.5An encoding collision raises IdentityCollisionError instead of merging nodes.
Open the full workbench
Section titled “Open the full workbench”Choose Open in Garphield in the notebook view for the full workbench.
Return to notebook sends the edited project back to the same
GraphView.
Read next
Section titled “Read next”- Notebooks - control a live view, choose chrome, export HTML, and use the browser handoff.
- Raphtory - visualize temporal Raphtory graphs.
- Snowpark - materialize Snowpark tables into a project.
- Projects - load, save, and fingerprint
.gphfiles. - API reference -
GraphView, codecs, transport, and errors. - Tutorial: NetworkX round trip - one graph from a notebook into the workbench and back.