python-igraph API reference

List of all classes, functions and methods in python-igraph

class documentation

class GephiGraphStreamer(object):

View In Hierarchy

Class that produces JSON event objects that stream an igraph graph to Gephi using the Gephi Graph Streaming API.

The Gephi graph streaming format is a simple JSON-based format that can be used to post mutations to a graph (i.e. node and edge additions, removals and updates) to a remote component. For instance, one can open up Gephi (http://www.gephi.org), install the Gephi graph streaming plugin and then send a graph from igraph straight into the Gephi window by using GephiGraphStreamer with the appropriate URL where Gephi is listening.

Example:

>>> from cStringIO import StringIO
>>> from igraph import Graph
>>> buf = StringIO()
>>> streamer = GephiGraphStreamer()
>>> graph = Graph.Formula("A --> B, B --> C")
>>> streamer.post(graph, buf)
>>> print(buf.getvalue())        # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
{"an": {"igraph:...:v:0": {"name": "A"}}}
{"an": {"igraph:...:v:1": {"name": "B"}}}
{"an": {"igraph:...:v:2": {"name": "C"}}}
{"ae": {"igraph:...:e:0:1": {...}}}
{"ae": {"igraph:...:e:1:2": {...}}}
<BLANKLINE>
Method __init__ Constructs a Gephi graph streamer that will post graphs to a given file-like object or a Gephi connection.
Method iterjsonobj Iterates over the JSON objects that build up the graph using the Gephi graph streaming API. The objects returned from this function are Python objects; they must be formatted with json.dumps before sending them to the destination.
Method post Posts the given graph to the destination of the streamer using the given JSON encoder. When encoder is None, it falls back to the default JSON encoder of the streamer in the encoder property.
Method send_event Sends a single JSON event to the given destination using the given JSON encoder. When encoder is None, it falls back to the default JSON encoder of the streamer in the encoder property.
Instance Variable encoder Undocumented
Instance Variable format Undocumented
def __init__(self, encoder=None):

Constructs a Gephi graph streamer that will post graphs to a given file-like object or a Gephi connection.

encoder must either be None or an instance of json.JSONEncoder and it must contain the JSON encoder to be used when posting JSON objects.

def iterjsonobj(self, graph):

Iterates over the JSON objects that build up the graph using the Gephi graph streaming API. The objects returned from this function are Python objects; they must be formatted with json.dumps before sending them to the destination.

def post(self, graph, destination, encoder=None):

Posts the given graph to the destination of the streamer using the given JSON encoder. When encoder is None, it falls back to the default JSON encoder of the streamer in the encoder property.

destination must be a file-like object or an instance of GephiConnection.

def send_event(self, event, destination, encoder=None, flush=True):

Sends a single JSON event to the given destination using the given JSON encoder. When encoder is None, it falls back to the default JSON encoder of the streamer in the encoder property.

destination must be a file-like object or an instance of GephiConnection.

The method flushes the destination after sending the event. If you want to avoid this (e.g., because you are sending many events), set flush to False.

encoder =

Undocumented

format =

Undocumented