Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paulgb/nbgraph
Inline, interactive graphs inside jupyter/ipython notebooks
https://github.com/paulgb/nbgraph
Last synced: 3 days ago
JSON representation
Inline, interactive graphs inside jupyter/ipython notebooks
- Host: GitHub
- URL: https://github.com/paulgb/nbgraph
- Owner: paulgb
- License: other
- Created: 2016-12-02T02:16:39.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-19T17:49:36.000Z (about 7 years ago)
- Last Synced: 2024-10-11T12:18:16.788Z (about 1 month ago)
- Language: Python
- Size: 4.58 MB
- Stars: 16
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
nbgraph
=======Interactive graph exploration inside of a Jupyter notebook. Graphs are rendered
with [sigma.js](http://sigmajs.org/).![screenshot](screenshot.gif)
Installation
------------Install is as simple as:
pip install nbgraph
Use
---Graphs are represented with the `NotebookGraph` class. Although manual
graph construction is possible with the `add_node` and `add_edge` methods, the
anticipated use-case is that the user will create or load a graph with another
library and use the `nbgraph` represenation only for the final display of the
graph. With this in mind, `nbgraph` comes with loaders for working with graphs
represented by [igraph](http://igraph.org/) or [networkx](https://networkx.github.io/).Quick-start Examples
--------------------See the `examples` directory for the examples as Jupyter notebooks.
## igraph
from nbgraph.loaders.igraph_loader import load_graph
import igraph
G = igraph.Graph.Atlas(381)
load_graph(G)## networkx
from nbgraph.loaders.networkx_loader import load_graph
import networkx as nx
G=nx.dodecahedral_graph()
load_graph(G)Notebooks with multiple graphs
------------------------------If you use multiple graphs within the same notebook, you will see a warning
about `nbgraph` being loaded multiple times. This is because the Python code
can't reliably know what's loaded in the JavaScript, so it tries to load it
every time a graph is displayed. This means sending the entire graph rendering
code for each graph, which can explode the size of an `.ipynb` file.To avoid this, use `prepare_notebook`:
from nbgraph.renderer import display_notebook, prepare_notebook
prepare_notebook()Then, use `display_notebook` with an extra `False` argument to display the
graph:my_graph = load_graph(G)
display_notebook(load_graph(my_graph), False)