edgegraph.output.pyvis

edgegraph.output.pyvis#

Create graphs using the PyVis framework.

This module supports exporting networks for, and shortcutting the display of, PyVis networks / graphs. This feature is only available if the pyvis module is installed – otherwise, attempting to import this module will raise an ImportError detailing this and how to install pyvis.

PyVis itself provides an interactive, HTML-based rendering of graphs. Users can zoom, pan around graphs, and click-and-drag the nodes themselves. Nodes and edges can be individually labelled, colors, sizes, and weights can be applied, and the physics model can be optionally be changed via the UI’s customizations. See PyVis’s documentation for more information, and demos.

Generally, the usage pattern for this module is intended to be as:

 1from edgegraph.builder import randgraph
 2from edgegraph.output import pyvis
 3
 4uni = randgraph.randgraph()
 5
 6if you_want_customizable_ui:
 7    pvn = pyvis.pyvis_render_customizable(uni, rvfunc=lambda v: str(v.i))
 8else:
 9    pvn = pyvis.make_pyvis_net(uni, rvfunc=lambda v: str(v.i))
10
11# notebook=False for usage outside of a Jupyter notebook.  this call will
12# block as the web browser opens to show the HTML file
13pvn.show("example.html", notebook=False)

Functions

make_pyvis_net(uni[, rvfunc, refunc, ...])

Convert a given Universe to a PyVis network, suitable for further use within PyVis.

pyvis_render_customizable(uni[, rvfunc, ...])

Convert a given Universe to a PyVis network, suitable for further use within PyVis.