Python Scripting Console for Gephi

The first release of the Gephi’s Python Console plugin is finally available for download. Through this plugin, you can execute queries and manipulate the graph structure by typing commands on a scripting console, making it a very powerful and concise tool to work with.

This console started as a joint proposal with the GUESS project which aimed at porting the Gython language as a console plugin for Gephi during the Google Summer of Code 2011 program. This project was mentored by Eytan Adar, from the GUESS project, and co-mentored by Mathieu Bastian, from Gephi.

After installation, the plugin can be accessed through the left slide on Gephi’s UI or through the Window > Console.

console

Among the features available through the console scripting language are:

  • Inspired by the Gython language from the GUESS project (i.e. additional operators for manipulating graphs).
  • Based on Jython 2.5.2, which implements the Python 2.5 specification.
  • Graph structure and attributes manipulation.
  • Filtering support.
  • Support for running layouts.
  • Export API support (i.e. generate PDF/GEXF/PNG exports from within the console).
  • Batch scripts support for automating tasks.
  • Loads third-party Python libraries.

For example, if you would like to filter the male persons from your social graph and make the result visible, you could simply type the following command:

visible = g.filter(gender == "male")

If you want set this subgraph nodes’ color to blue, you could just type:

g.filter(gender == "male").nodes.color = blue

Or, even better, if you want to color both the nodes and edges of this same subgraph, just type:

(gender == "male").color = blue

Implementing batch scripts for automating tasks is very easy. Just save the script as a file with the py extension and load it with the execfile function. For instance, a batch script for creating a random graph with 50 nodes would look like this:

scripting_random_graphs

And to run the script, you would call the following command on the console:

>>> execfile("C:\Users\user\Documents\script.py")

Installation

The Scripting Plugin can be installed through the Gephi’s Tools/Plug-ins menu:

  1. Go to the Tools > Plug-ins menu on Gephi’s user interface.
  2. Open the Available Plugins tab.
  3. Click the “Reload Catalog” button, to make sure you have an up-to-date catalog.
  4. Select the “Scripting Plugin” on the list and click the Install button.

After installation, the plugin can be accessed through the left slide on Gephi’s UI (as shown in the image below) or through the Window > Console menu.

Documentation

The console’s documentation at the wiki has instructions for downloading and installing the plugin.

Feedback and Contributing

This plugin has been developed by Luiz Ribeiro since the Google Summer of Code 2011 program and we’re really looking forward to see what you’ll be able to do with this new tool.

The plugin’s source code is hosted on GitHub and is open to your contributions. If you find any bugs or have requests or feature ideas make sure to open a new ticket on the Issues Tracker.

3 Comments

  1. It seems to me like a perfect tool to create dynamic views in the overview! Combined with a video screen capture, this could lead to nice animations!
    (for those of us who are still a bit slow on learning the Gephi toolkit…)

    Reply

  2. Once this is loaded, is it possible to run Gephi in batch-mode, so that all graphics are processed without actually trying to draw anything to the screen? I have a VERY HUGE graph that I would like to convert from one format to another, and if I can do this all from within Python, it would be preferable to opening up a Gephi session and running this console interactively.

    See my posts on https://stackoverflow.com/questions/23619892/gephi-batch-mode and https://github.com/gephi/gephi/issues/915

    Reply

Leave a comment