Jupyter Widget

After installing and enabling the Jupyter widget, you can use the library within a notebook in the following way:

import algorithmx

# Create a Jupyter canvas interface
canvas = algorithmx.jupyter_canvas()

# Set the size of the canvas
canvas.size((300, 200))

# Use the library normally, for example:
canvas.nodes([1, 2]).add()
canvas.edge((1, 2)).add()

# Display the canvas

Note that you need to hold down the ctrl/cmd key to zoom in. If you are creating an algorithm simulation, you can also enable start/stop/restart buttons:

canvas = algorithmx.jupyter_canvas(buttons=True)
algorithmx.jupyter_canvas(buttons: bool = False) → algorithmx.jupyter.JupyterCanvas.JupyterCanvas[source]

Creates a new CanvasSelection which will dispatch and receive events through a Jupyter widget, and which can be displayed using the IPython display function.

By default, the canvas size is (400, 250), and requires the ctrl/cmd to be held down while zooming.