Skip to main content

Interactive Graph Editor for Jupyter

An interactive graph editor function designed for Jupyter notebooks. edit(graph: nx.Graph) function allows users
to manipulate a graph by creating vertices, edges, and adding labels directly within a Jupyter environment.

Parameters

  • graph (networkx.Graph): The graph object to be edited. It should be an instance of the NetworkX Graph class or a subclass.
  • color_dict (Dict[str, str]): Map of color labels into HTML colors, empty by default.

Functions of buttons (from left to right)

  1. Select if you want to edit graph structure.
  2. Select if you want to edit labels.
  3. Select if you want for nodes to be clickable. Deselecting this should make it easier to operate on edges in a large graph.
  4. Select if you want for edges to be clickable. Deselecting this should make it easier to operate on nodes in a large graph.
  5. Turn on/off physics.
  6. Turn on/off fancy drawing (planar representation of a graph, works only for 3-connected planar graphs).
  7. Enable/disable labels.
  8. Exit the editor.

Mouse Functions

  1. Click and drag vertices to move them around the canvas.
  2. To create an edge, click on one vertex and then click on another vertex.
    An edge will be created between the two selected vertices.
  3. To create a vertex, click on empty space on the canvas.
  4. To delete an object, double-click on it.

Dependencies

  • Jupyter notebook web environment.
  • NetworkX library for graph manipulation.

Notes

This function relies on Jupyter ipywidgets, so it should work only in web versions of Jupyter. (It is possible to run editor in VSCode but it is not guaranteed that it will work properly or even run at all.)

Installation instructions

go to: https://pypi.org/project/graph-editor-jupyter/
or run:

pip install graph-editor-jupyter

Examples

Creating and editing a new graph

import networkx as nx
from graph_editor_jupyter import edit

# Create a sample graph
simple_graph = nx.Graph()
simple_graph.add_node(1)
simple_graph.add_node(2)
simple_graph.add_edge(1, 2)

# Open simple_graph in the editor
edit(simple_graph)

Labels and graph coloring

import networkx as nx
from graph_editor_jupyter import edit

labeled_graph = nx.Graph()

# Add nodes with labels (labels can be also edited and added in the editor)
labeled_graph.add_node(1, label_name='A')
labeled_graph.add_node(2, label_name='B')
labeled_graph.add_edge(1, 2)

# Add nodes with colors, label with name 'color' (additional colors can be added in the editor)
labeled_graph.add_node(3, color='c')
labeled_graph.add_node(4, color='g')
labeled_graph.add_edge(3, 4)

# Define custom colors for labels (otherwise random colors are used)
# label_colors={'color label': 'HTML color (Hex RGB or name)'}
label_colors={'c' : '#00FFFF', 'g': 'green'} 

# Open labeled_graph in the editor
edit(labeled_graph, label_colors)

Displaying planar representation* of a graph

*You can use fancy drawing for 3-connected planar graphs
import networkx as nx
from graph_editor_jupyter import edit

# Create a sample planar and 3-connected graph
petersen_graph = nx.petersen_graph()

# Open petersen_graph in the editor
edit(petersen_graph)

# To display planar representation of a graph, in the editor, 
# change the drawing mode to 'fancy drawing' (6th button from the left) 

Metadata

Release files for graph-editor-jupyter 0.0.7

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

Source distribution (sdist)

Source distribution for graph-editor-jupyter 0.0.7
File Size Uploaded
graph_editor_jupyter-0.0.7.tar.gz 16.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for graph-editor-jupyter 0.0.7
File Interpreter ABI Platform
graph_editor_jupyter-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 33.5 kB

Release files / graph_editor_jupyter-0.0.7.tar.gz

Download URL graph_editor_jupyter-0.0.7.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1cd5f3256ee1965dd9b7c718627aeb415e909c977877d4b8a8df3a2815f741b3
BLAKE2b-256 checksum
How to use checksums
558f0fc9936b65c1aabb28822439ed82c575480b51720e929d17afb1d7d68398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / graph_editor_jupyter-0.0.7-py3-none-any.whl

Download URL graph_editor_jupyter-0.0.7-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
250ec5ab99746bf42ec4c5cc61c000143c0cf83a857d6c64cf5d9b3729184367
BLAKE2b-256 checksum
How to use checksums
aac46b00bc5c4dedf2a85e4689b79c0b66dfa021056d29098d5e70c90d0b69c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

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