AlgorithmX Python is a library for network visualization and algorithm simulation, built on AlgorithmX. It works through either a WebSocket server, or as a widget in Jupyter Notebooks and JupyterLab.
Python 3.6 or higher is required.
AlgorithmX can be installed using pip:
pip install algorithmx
In classic Jupyter notebooks, the widget will typically be enabled by default. However, if you installed using pip with notebook version <5.3, you will have to manually enable it by running:
jupyter nbextension enable --sys-prefix --py algorithmx
with the appropriate flag. To enable in JupyterLab, run:
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install algorithmx-jupyter
If you wish to use the library through a HTTP/WebSocket server, follow the template below:
import algorithmx
server = algorithmx.http_server(port=5050)
canvas = server.canvas()
def start():
canvas.nodes([1, 2]).add()
canvas.edge((1, 2)).add()
canvas.listen('start', start)
server.start()
Be default, the output can be found at http://localhost:5050/
.
If you are using Jupyter, add the following to a cell:
import algorithmx
canvas = algorithmx.jupyter_canvas()
canvas.nodes([1, 2]).add()
canvas.edge((1, 2)).add()
display(canvas)
If you aren't using docker, you can install the package locally:
cd js
npm run build
npm run inject
cd ..
pip install --no-deps --editable .
With docker:
docker-compose up http-server
Manually:
python -u examples/basic_http_server.py
Then, in both cases, open localhost:5050
in a browser.
With docker:
docker-compose up notebook
You will need to follow the link which appears in the output.
Manually:
jupyter nbextension install --symlink --sys-prefix --py algorithmx
jupyter nbextension enable --sys-prefix --py algorithmx
jupyter notebook
Then, in both cases, navigate to examples/basic.ipynb
.
rm -rf build dist
With docker:
docker-compose up --build build
Manually:
python setup.py build sdist bdist_wheel
In both cases, the bundle can be found in dist/
.