Download
Demo
Sample Data
Links
Tutorial

Author

Social Networks Library for Processing

This library provides facilities for working with network data within Processing.   It contains some of the usual jazz found in a network library (layouts, i/o), but emphasizes tools for selecting subsets of and traversing the network in manners conducive to applying effects.

Download
jar (beta, v0.1) [API][with source]

Demo
A Random Walk Thru Wikipedia Science Categories [source][Windows][Linux][Mac osX][Applet]

Demo Screenshot

Sample Data
Wikipedia Science Categories for 09-28-2006

Links
Processing
Processing Libraries
Processing Blogs

Tutorial

We'll create a very simple network, select a node from it, and change the aesthetics...

Step 1: From within the Processing Sketchbook, include the library and initialize the network. The library jar file must be in the subdirectory /code of your sketch's directory.

import socialNetworks.*;
Network net = new Network(this);

Step2: Create a network. Alternatively we could have loaded a network form file as long as its in the Pajek format.

void setup(){
size(250,250);
Node a = new Node(this, "Node A", 25, 25);
Node b = new Node(this, "Node B", 200, 25);
Node c = new Node(this, "Node C", 25, 200);
net.addNode(a);
net.addNode(b);
net.addNode(c);
net.addEdge(new Edge(this, a, b));
net.addEdge(new Edge(this, b, c));
net.addEdge(new Edge(this, c, a));
}

Step 3: Set the global aesthetic properties by using addAll() to first add all nodes and edges to the active selection.

void draw(){
background(150,150,150);

//global properties
net.selection.addAll();
fill(color(255,255,255));
net.selection.showLabels();
net.selection.edgeColor(color(255,255,255));

Step 4: Change the properties of 'Node C' . First deselect all nodes and edges with removeAll(). Then add 'node C' to the active selection by looking up its title. We then change the size and color of the active selection, which is now just one node.

//focus on a particular node
net.selection.removeAll();
net.selection.addNodesByTitleExactMatch("Node C");
net.selection.nodeSize(10);
net.selection.nodeColor(color(255,0,0));
net.draw();
}

The resulting sketch looks like this...

Tutorial Sketch

Todd Holloway, PhD Student, Computer Science, Indiana University . Todd.Holloway at gmail.com.