igraph
An embeddable webGL graph visualization library.
http://patrickfuller.github.io/igraph/
Examples
IPython
The IPython notebook is an open-source tool poised to replace MATLAB in many
applications. As a scientist of sorts, I'm all about it. Therefore, I made
handles to use igraph with the notebook. Install through pip:
pip install igraph
Open a new notebook and test the setup by typing:
import igraph
igraph.draw([(1, 2), (2, 3), (3, 4), (4, 1), (4, 5), (5, 2)])
into a notebook cell. You should get a paddlewheel graph as an output. You can
use this in conjunction with other code for educational purposes (try generating
a red-black tree!). There are three commands and some optional parameters to
check out. Read the docstrings and check out the associated
example for more.
Javascript
You can install through npm:
npm install igraph
Once installed, you can use with:
igraph.create('my-selector');
igraph.draw(myGraph);
where 'my-selector'
is where you want to place igraph, and myGraph
is a
javascript object. See below for more on the object structure, or just check out
the included example. The igraph.create()
method takes a few optional
parameters, specifying the sizes and colors of nodes, as well as force-directed
optimization.
options = {
directed: true,
nodeSize: 2.0,
edgeSize: 0.25,
arrowSize: 1.0,
defaultNodeColor: 0xaaaaaa,
defaultEdgeColor: 0x777777,
shader: "toon",
runOptimization: true
};
Graph Data Format
igraph takes input graph data structures as plain objects. Here's the most
boring graph in the world:
{
nodes: {
jane: { },
bob: { },
mike: { },
sally: { }
},
edges: [
{ source: "jane", target: "bob" },
{ source: "bob", target: "mike" },
{ source: "mike", target: "sally" }
]
}
Nodes require no information outside of their keys. However, there are useful
optional parameters that can be specified.
{
color: 0xffffff,
size: 1.0,
location: [0.0, 0.0, 0.0]
}
By default, the algorithm runs a force-directed layout on the graph. When
enabled, the "location" field is optional. However, for larger graphs, you will
want to disable this feature and pre-render the locations. Use the associated
Python library (igraph.generate
) to do so.