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.
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:
And to run the script, you would call the following command on the console:
The Scripting Plugin can be installed through the Gephi’s Tools/Plug-ins menu:
- Go to the Tools > Plug-ins menu on Gephi’s user interface.
- Open the Available Plugins tab.
- Click the “Reload Catalog” button, to make sure you have an up-to-date catalog.
- 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.
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.