Gephi streaming from python igraph

It is a nightmare to do visualization in python igraph, at least for me. After hours tweaking cairo and pycairo and distorted node labels, I found an alternative route – push graphs to Gephi from igraph. And what’s cool about it, I can update my graph dynamically!

  1. Download the streamer plugin fro gephi
  2. start the master server in gephi
  3. Run the following python code.

import igraph as ig
import igraph.remote.gephi as igg

# Create graph
g = ig.Graph([(0,1), (0,2), (2,3), (3,4), (4,2), (2,5), (5,0), (6,3), (5,6)]
g.vs[“name”] = [“Alice”, “Bob”, “Claire”, “Dennis”, “Esther”, “Frank”, “George”]
g.vs[“age”] = [25, 31, 18, 47, 22, 23, 50]
g.vs[“gender”] = [“f”, “m”, “f”, “m”, “f”, “m”, “m”]
g.es[“is_formal”] = [False, False, True, True, True, False, True, False, False]

# Send to Gephi
gephi=igg.GephiConnection()
streamer=igg.GephiGraphStreamer()
streamer.post(g,gephi)

# Update graph
api = igg.GephiGraphStreamingAPIFormat()
event=api.get_add_node_event(“1″, dict(label=”eggs”))
streamer.send_event(event,gephi)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s