A library for network visualization and algorithm simulation.
Project description
AlgorithmX Python
AlgorithmX Python is a library for network visualization and algorithm simulation, built on AlgorithmX. It can be used through a HTTP/WebSocket
server, or as a widget in Jupyter Notebooks and JupyterLab.
Resources
Installation
Python 3.7.0 or higher is required. Using pip:
python -m pip install algorithmx
Jupyter Widget
In classic Jupyter notebooks, the widget will typically be enabled by default. To enable it manually, run
jupyter nbextension enable --sys-prefix --py algorithmx
with the appropriate flag. To enable in JupyterLab, run
python -m jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build
python -m jupyter lab build
Example Usage
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.onmessage('start', start)
server.start()
The graphics can be found at http://localhost:5050/
.
If you are using Jupyter, try adding the following code to a cell:
from algorithmx import jupyter_canvas
canvas = jupyter_canvas()
canvas.nodes([1, 2]).add()
canvas.edge((1, 2)).add()
canvas
Development
Manual install
Make sure you have Python 3.7 of higher, then run
# build js
cd js
npm run build
cd ..
# install dependencies
python -m pip install -r dev-requirements.txt
python -m pip install --no-deps --editable ".[jupyter,networkx]"
HTTP Server
Docker: Docker-compose up http-server
Manually: python examples/basic_http_server.py
Then open localhost:5050
in a browser.
Jupyter notebook
Docker: docker-compose up notebook
Manually:
python -m jupyter nbextenion list
python -m jupyter notebook
Then try opening examples/basic_notebook.ipynb
.
Jupyter lab
Docker: docker-compose up jupyter-lab
Manually:
python -m jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build
python -m jupyter lab build
python -m jupyter labextension list
python -m jupyter lab
Then try opening examples/basic_notebook.ipynb
.
Build and test package
Clean any previous builds with rm -rf build dist
.
Docker: docker-compose up --build build
Manually:
python -m mypy .
python -m pytest tests -vv
python setup.py build sdist bdist_wheel
The bundle can be found in dist/
.
Distribute
- Set up pre-commit hooks:
pre-commit install
- Publish to PyPI:
./scripts/deploy.sh
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file algorithmx-2.0.3.tar.gz
.
File metadata
- Download URL: algorithmx-2.0.3.tar.gz
- Upload date:
- Size: 950.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 354585a02883e096d6ecacd06a95c138344b419bda1ae0f480965861dbd051d8 |
|
MD5 | c00a4decf7f04fc72f5a614e3386194e |
|
BLAKE2b-256 | a8d1e293d0ed901dae76e18ea98606a9a6e6967f988857ed908101292ee031c8 |
File details
Details for the file algorithmx-2.0.3-py3-none-any.whl
.
File metadata
- Download URL: algorithmx-2.0.3-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91d10a048671b5b0f741dfb9b8c7d8a8aa11d7351ed4f90870e2ca7118c9139f |
|
MD5 | 78384f3ba0720cc31d2c080aeec48239 |
|
BLAKE2b-256 | 76f1bdef3135164119089fa0109a0362ca6ee4a01ca212d8c46476eff7529a16 |