Skip to main content

A graph editor for SageMath/Jupyter

Project description

Phitigra

Binder

Phitigra is a graph editor widget for SageMath when using the Jupyter notebook.

Try the demo notebook on mybinder!
Note: for some unknown reason the above link stopped working.

Features

With phitigra one can:

  • draw graphs using the mouse to add vertices and edges
  • move the vertices positions, zoom in and out
  • draw undirected as well as directed graphs
  • choose the color of vertices and edges
  • apply various layout algorithms
  • easily retrieve the drawn graph for use with SageMath
  • run step-by-step a custom script on the drawn graph
  • change and refresh the drawing with external functions

Non-features

The following are not supported:

  • multigraphs: multiple edges will not be drawn
  • large graphs: the rendering will be unpraticably slow

Dependencies

With jupyter, you might need the following

jupyter nbextension enable --py widgetsnbextension

after you install ipywidgets, and possibly more if using virtualenv and working in an activated virtual environment, see ipywidget's documentation for full details.
This is the first thing to check if the import of the package works fine but nothing shows when you try to display the widget.

With jupyterlab, the jupyterlab_widgets package is also required for the widget to show.

How to try it?

On mybinder

(Runs online, nothing to install.)

Note: for some unknown reason the link below stopped working. Clicking here will open the demo notebook on mybinder in a new tab. Note that this uses the stable version of phitigra (that from the master branch), which may differ from the one in the develop branch.

From a standalone SageMath installation

This assumes that SageMath is installed on your system. See http://www.sagemath.org for install instructions.

Stable version

The stable version is on pypi so it can be installed as follows

sage -pip install --upgrade phitigra

Development version

Clone the source from the repository

git clone https://github.com/jfraymond/phitigra.git

Install or upgrade with pip:

sage -pip install --upgrade path/to/the/cloned/repository

That's it!

To uninstall:

sage -pip uninstall phitigra

Note that the above commands should not be run from the repository directory, otherwise pip might complain that it did not find files to uninstall.

Usage

from phitigra import GraphEditor
editor = GraphEditor(graphs.RandomGNP(10, 0.5))
editor.show()
# Now you can play with the graph!

A copy of the currently drawn graph can be obtained with the get_graph function:

G = editor.get_graph()
# Now G is a copy of the graph drawn in editor e

There are many more examples in the demo notebook.

Tests

As with SageMath's code, tests and code quality checks can be started with the --tox option (from the cloned directory):

sage --tox src/phitigra

Building the documentation

From the package directory

cd docs
sage -sh -c "make html"

The main file of the documentation is then in docs/build/html/index.html. A recent build of the documentation can be found here.

What's new

v0.2.6

  • Minor change to adapt to the new ipycanvas; this version will not work with ipycanvas < 0.12.0

v0.2.5

  • Minor fixes in the documentation
  • Fixed an issue when building the documentation

v0.2.4

  • Show/hide edge labels
  • User-defined vertex labels
  • Exposing vertex positioning functions
  • Removing the Next button
  • Updating links after move to github
  • More examples in the demo notebook

v0.2.3

  • Improved doc
  • Polished code, which now passes all tests
  • Changed package structure to follows python guidelines

v0.2.2

  • Single (major) change: renaming SimpleGraphEditor into GraphEditor. Code written for previous versions is not compatible with this one, but can be easily fixed.

v0.2.1

  • Demo notebook
  • Binder link
  • Improved update time when moving vertices
  • Minor fixes

v0.2.0

  • Docstrings and doctests in (almost) all functions
  • Hiding of internal objects
  • Cleaning code

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phitigra-0.2.6.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

phitigra-0.2.6-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file phitigra-0.2.6.tar.gz.

File metadata

  • Download URL: phitigra-0.2.6.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for phitigra-0.2.6.tar.gz
Algorithm Hash digest
SHA256 36cdc745316b876a4f675212b9a994439d2d9a1b3b12c4e8cce4a149304a9ba0
MD5 f66c79d2d791a0d04f093b5907ce9ae6
BLAKE2b-256 3cc07d942f71c6aa9cdf7f80072cc1c07614e6d25806d9e3da21d432da7dd769

See more details on using hashes here.

File details

Details for the file phitigra-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: phitigra-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for phitigra-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ca7ca9759d88c2bbde420d779c4c22091fc4789fad9f676c7628a6f0ceb23627
MD5 1969e52de630c3cbf7773d3631e36585
BLAKE2b-256 293578a663ad20aa8e4c29af39e842758a38d1a4678a4d6a75ccc674aee86544

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page