用于网络可视化和算法模拟的库。
algorithmx的Python项目详细描述
algorithmx python
algorithmx python是一个基于AlgorithmX的网络可视化和算法模拟库。它可以通过http服务器工作,也可以作为jupyter笔记本和jupyterlab中的小部件工作。
资源
安装
Python3.6或更高版本是必需的。
algorithmx可以使用pip安装:
pip install algorithmx
Jupyter小部件
在经典的jupyter笔记本中,小部件通常在默认情况下启用。但是,如果在笔记本版本<;5.3中使用pip安装,则必须通过运行以下命令手动启用它:
jupyter nbextension enable --sys-prefix --py algorithmx
用appropriate flag。要在jupyterlab中启用,请运行:
jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter labextension install algorithmx-jupyter
示例用法
如果希望通过http/websocket服务器使用库,请遵循以下模板:
importalgorithmxserver=algorithmx.http_server(port=5050)canvas=server.canvas()defstart():canvas.nodes([1,2]).add()canvas.edge((1,2)).add()canvas.listen('start',start)server.start()
默认情况下,可以在http://localhost:5050/
找到输出。
如果您使用的是Jupyter,请在单元格中添加以下内容:
importalgorithmxcanvas=algorithmx.jupyter_canvas()canvas.nodes([1,2]).add()canvas.edge((1,2)).add()display(widget)