gephi plugin developer workshop

63
Mathieu Bastian <[email protected]> Mountain View, California October 2011 Gephi Plugin Developer Workshop

Upload: gephi-consortium

Post on 26-Jan-2015

116 views

Category:

Technology


1 download

DESCRIPTION

Gephi Plugin Devleoper Workshop, October 6, 2011 in Mountain View, California.Presentation of Gephi's architecture and the different types of plugins that can be written with examples. Details about Gephi's API, code examples and best practices are presented. The Gephi Toolkit is also covered.

TRANSCRIPT

Page 1: Gephi Plugin Developer Workshop

Mathieu Bastian<[email protected]>

Mountain View, CaliforniaOctober 2011

Gephi Plugin Developer Workshop

Page 2: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Welcome!

Introduction to Gephi

Why building plug-ins?

Netbeans Platform

Gephi’s Architecture

Plug-ins example

Gephi Toolkit

Live coding

Page 3: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Introduction to Gephi

• A project started in 2007

• An Exploratory Network Analysis Tool

• An open-source platform

• Written in Java, Swing, OpenGL

Gephi is…

Page 4: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Introduction to Gephi

• A website, a wiki, a bug tracker, a forum and a mailing-list

• A modular and extensible architecture

• A codebase of ~180K lines of code

• Long-term plans and roadmap

• A Manifesto

Gephi has…

Page 5: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Introduction to Gephi

• Performance, Usability and Modularity (and Stability!)

• The platform, easy to use and extend

• Networks. No diagrams or other visualizations.

• Standards and open innovation

Gephi focus on…

Page 6: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Introduction to Gephi

• Modular architecture The secret sauce for a sustainable code

• Interoperability Use, improve or create standards

• Integration Be exigent with UI, installation, platforms

• Open and transparent Ideas and features come from the community

• Public good Is and will remain open-source

• Documentation Provide tutorials and rich Javadoc

The Platform’s vision

Page 7: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Why building plug-ins?

• Networks are everywhere

Social Networks, Biological Networks, Power grid, Software, Innovation… The complex world produces networks to visualize and analyze.

• Gephi is a generic software for all networks

The variety of networks, data sources and algorithms is huge. Gephi can’t support all of them by default so we need plug-ins.

Page 8: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Why building plug-ins?

• It’s easy to build and update

Plug-ins are easy to create and release. Development is integrated in Netbeans IDE. No JAR hell. Easy to release new version through Gephi’s website.

• Hack vs Plug-ins

Plug-ins are an incentive to build sustainable modules and share them. One can always take the source code and hack it to get things done but there is an real advantage to built on top of clean APIs.

Page 9: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Gephi architecture

Page 10: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Netbeans Platform

"The NetBeans Platform is a generic framework for Swing applications. It provides the "plumbing" that, before, every developer had to write themselves”

Description and tutorials

Quick Start

API Index

Page 11: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Netbeans Platform

• Gephi is built on top of Netbeans Platform.

• So, development is fully integrated in Netbeans IDE:

• Download Gephi’s sources

• File > Open Project in Netbeans

• Browse existing modules or create new

• Run Gephi. Click on Run!

Page 12: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Netbeans Platform

In a few words…

• Netbeans Platform provides to Gephi the module system, the window system, the localization system, the preferences system and more…

• Gephi development is integrated within Netbeans IDE.

• A Netbeans Platform application (like Gephi) is basically a suite of modules.

• Each module has a title, a description, a version, an author and hopefully a well defined role in the application.

• Modules expose public APIs and depend on each other (without circular dependencies).

Page 13: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Gephi Architecture

Page 14: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Gephi APIs

• Graph API

• Attributes API

• Import API

• Layout API

• Statistics API

• Filters API

• Ranking API

• Partition API

• Project API

• Preview API

• Export API

• DataLab API

• Dynamic API

• Generator API

• LongTask API

• Visualization API

Read more on the Javadoc

Page 15: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Gephi APIs

• Each API has a role and a set of public packages other modules can use

• Consult the Javadoc to see what an API does and browse classes

• While the software evolve, APIs remain backward compatible

• When we do changes on APIs, we wrote changes in the “API Changes” section on the Javadoc front-page

• If you see an undocumented API, contact us or report a bug

Page 16: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Gephi SPIs

SPI vs API…

• API: Can be called to do something. For instance a module call the LayoutAPI to run a layout algorithm for 100 iterations.

• SPI: Interface to be implemented. For example a plug-in implements the Layout interface to add a new layout

SPIs is the classical way how features are implemented in Gephi (and Netbeans). You’ll see some packages ending with ‘spi’ in the Javadoc.

Page 17: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Gephi SPIs

• Import SPI

• Layout SPI

• Statistics SPI

• Filters SPI

• Ranking SPI

• Generator SPI

• DataLab SPI

• Partition SPI

• Preview SPI

• Export SPI

• Perspective SPI

• Tools SPI

• Workspace Persistence SPI

Page 18: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Graph API

Hosts the Graph data. A graph is a collection of nodes and edges and could be directed, undirected or mixed.

• Iterate over nodes, edges or add/remove items.

• Get node counts, degrees, neighbors…

• Subscribe to graph events

• Create sub-graphs (views)

• Supports hierarchical graphs (graphs within graphs)

• No parallel edges

Page 19: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Attributes API

Each node/edge can have additional data, called attributes. Attributes can be any primitive type (Integer, Boolean, String, …), lists or dynamic.

• Add/Remove columns

• Columns are identified by an id and a title.

• Push data to nodes/edges specifying the column

Id Label Age Gender

n1 Johm 26 Male

n2 Margaret 46 Female

Page 20: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Import API

Imports data from any support (files, databases. streams). Import is a two-step process: first step adds all data to a container and second step appends the container to the workspace.

• Import data to a new workspace or merge it to an existing

• Verify the content of the container, fill a log/warning/error report

• Automatically merge parallel edges

• Doesn’t support real-time import

Page 21: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Layout API

Provides real-time layout algorithm execution. Layouts do nothing else than modify the X and Y coordinates of nodes.

• Control layout execution

Page 22: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Statistics API

Provides the statistics/metrics algorithm execution framework. Statistics typically use the network data to create results for each node/edge (degree, clustering coefficient, hits, …) or global.

• Synchronous or asynchronous algorithm execution

• Supports progress tracking and cancellation

• Get HTML reports from statistics execution

• Execute dynamic statistics with sliding window support

Page 23: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Filters API

Provides the framework to filter the graph and obtain a filtered sub-graph (a view). A filter can be a simple boolean predicate (age > 30) or a more complex process (k-core). Filters have parameters.

• Execute a filter and obtain the sub-graph

• Create more advanced filter queries with operators (And, Or, Not…)

• Create advanced chained filter queries

• Export the filter result to a new workspace

Page 24: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Ranking API

Ranking uses numerical attribute columns to visually transform elements (nodes, edges). Typically changing the size or color of the element.

• Get all possible rankings for a type of element

• Transform nodes/edges with default transformers

• Define custom interpolations

• Enable auto-transformation. Simply a transformation automatically applied when the graph changes.

Page 25: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Partition API

Partitions are sets of nodes/edges with the same value for a particular column.

• Get the set of values for a particular columns and the collections of items for each value.

• Apply color transformation on the partition

• Transform a partition into a hierarchical graph

Page 26: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Project API

Project API hosts the project and workspace data. Workspaces are data containers which any module can access. If data has to be shared between modules it has to lie in the Workspace. That’s exactly where each model is supposed to be stored.

• Create, open and close projects and workspaces

• Retrieve and switch the current workspace

• Subscribe to the almighty Workspace events

Page 27: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Preview API

Preview is a flexible visual rendering framework with high level of customization. The input is the graph data and a style and the output is a network map ready to be exported to PDF, SVG or PNG.

• Renders the graph to Processing, PDF or SVG with the same visual output

• Customize all sort of things, from fonts to edge thickness or color

• Get a Processing viewer out of the box

Page 28: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Export API

Export’s role is to export graph or preview data to files or streams.

• Export graph data, for instance to a GEXF or GraphML file

• Export preview data, typically to PDF, SVG or PNG files

• For graph, one can choose to export the complete or only visible graph

Page 29: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Data Laboratory API

The Data Laboratory works with spreadsheets and provides a large number of actions to manipulate the graph. All actions available by either right-clicking on nodes/edges or in the toolbar are accessible in the API. For instance the Search/Replace feature.

• Manipulate columns, Import CSV, Merge elements, clear…

• Sophisticated merging strategies (sum, average, join…)

• Graph manipulation (group, delete, duplicate…)

• Search/Replace

Page 30: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Dynamic API

API dedicated to dynamic network states and events. Browsing dynamic networks uses the Timeline component and defines a ‘visible interval’. This API is responsible for holding and modifying that value.

• Retrieve/Set the current visible interval

• Get the current time format (date, double, datetime)

• Create DynamicGraph, a utility class to apply a sliding window on a dynamic graph

Page 31: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Generator API

Generators are algorithms to create networks from a set of properties. This API simply let users execute these algorithms in a thread.

• Execute a generator in a thread

• Provides progress and cancellation

Page 32: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

LongTask API

API used by other modules (Statistics, Generator, Import…) to execute long tasks in separate threads with progress, error and cancel support.

• Execute a LongTask in a separate thread with progress, error and cancel support

• Get informed when tasks finishes or returned errors

• Each LongTaskExecutor only supports one task at a time

Page 33: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Visualization API

Still in development. This API will eventually expose all options of the rendering engine and let users customize properties. It will also provide mouse events queues, selected elements lookup and off-screen screenshots.

Page 34: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Now SPIs…

SPIs define how Gephi can be extended. There are simple Java interfaces like Layout, Importer, Filter or Renderer.

When you implement a new SPI interface add a @ServiceProvider annotation to the class and that’s all you need to do to register your new implementation:

Page 35: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Import SPI

Extend the range of file formats or databases supported. An importer is reading a data source and pushing data to the import container.

• Add new file formats

• Add new types of databases

• Add new spigot (API, Socket, Stream…)

• Define custom import UI. The UI could be a single settings JPanel or a wizard.

How to write an Import

How to write a Spigot with Wizard

Page 36: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Layout SPI

Add new layout algorithms. A layout algorithm reads the graph and modify X and Y coordinates.

• Add new layout algorithm

• Define the layout properties

How to write a layout

Page 37: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Statistics SPI

Add new statistics algorithms. Statistics write result data for each node/edge and write HTML reports.

• Add new statistics algorithm

• Create a settings UI panel

• Supports standard and dynamic statistics

How to write a metric

Page 38: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Filters SPI

Filters are routines that remove nodes/edges from the graph given some parameters. Filters are built by “Builders” which act like factories. A filter builder can for instance build a filter for each attribute column. It’s called a category builder in that case.

• Create new filters and define parameters

• Create a settings UI which modify the parameters

• Create filter builders

How to write a filter

Page 39: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Ranking SPI

Ranking has a new SPI to create custom transformers. A transformer is transforming the node visual attributes given the list of values normalized between 0 and 1.

• Create new transformers

• Create the transformer UI, a custom JPanel

Page 40: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Generator SPI

Simple SPI for adding new generators. Generator implements the LongTask interface to support progress and cancellation.

• Create new generators

• Provide a settings UI

How to write a graph generator

Page 41: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

DataLab SPI

The Data Laboratory actions can be extended, whether it’s a contextual or general action.

• Create new node/edge context menu actions to manipulate one or multiple selected nodes/edges.

• Create a general action that will show up in the Toolbar

• Create a new action for manipulating attribute columns

• Create new merge strategies

How to extend Data Laboratory features

Page 42: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Partition SPI

The partition SPI allows to create new transformers. However this SPI is not stable yet and will be rewritten in a near future.

• Create new transformers

• Provide a settings UI

Page 43: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Preview SPI

Preview is a highly customizable module. Item builders built items from the graph data and renderers render these items to targets (Processing, SVG and PDF).

• Create new item builders or replace default implementations

• Create new renderers or replace default implementations

• Add new properties

• Add custom UI which will be displayed in an extra tab

How to write a preview renderer

Page 44: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Export SPI

There is three types of exports: Graph, Vector and custom.

• Support new graph format extension

• Support new type of vector-based file

• Create settings UI

• Create new type of custom export (ex: stream)

How to write an export

Page 45: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Perspective SPI

Perspectives are a set of panels. Typically “Overview”, “Data Laboratory” and “Preview” are perspectives.

• Create new perspectives

• Set which panels belong to a perspective

Register a perspective

Page 46: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Tools SPI

Tools are actions users can take on the graph and are presented in the toolbar at the left of the graph window. Tools register to graph events (Mouse click, drag, press, Node click, …) and take action.

• Create new tools

• Create property toolbar to configure the tool

Page 47: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Workspace Persistence SPI

Modules can implement the WorkspacePersistenceProvider interface to save/load data into .gephi project files. When the project is saved every implementation is asked to write XML data and an identifier. When the project file is opened the system find identifiers and give the XML to parse to the implementation.

• Add new data to the project file

Page 48: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Create a Plug-in (5 minutes)

What a plug-in really is…

A plug-in is nothing else than a Netbeans module packaged in a single file with a NBM extension. It’s basically a JAR with additional meta-data.

There is no differences between Gephi’s core modules and plug-ins. There are all Netbeans modules. In a sense Gephi is just a suite of plug-ins which work together and depend on each other.

To create a new module…

Once Gephi project is open, right click on “Modules” > “Add new…”

Page 49: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Create a Plug-in (5 minutes)

Right click on your module > Properties…

• Manage dependencies

Dependencies are explicit between modules. You control which other modules your module depends on. You also control which packages are publicly visible for other modules.

Your module will use APIs set by other modules and/or define its own APIs which others can use.

My Module

Depends on

Page 50: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Create a Plug-in (5 minutes)

Right click in your module > Properties…

• Module branding

Each module has a name, a description, a license, a version and an author.

When you update your module, increase the specification version number.

Page 51: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Create a Plug-in (5 minutes)

Right click on your module > Create NBM…

It creates a single file you can distribute and share.

Gephi’s website let you upload your NBM file out of the box. You can also update your plug-in with a new version.

For multi-modules plug-ins, it also accepts a zip package of several NBMs.

Page 52: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Plugin examples – Circular Layout

Adds a new Layout. Standard use of the Layout SPI.

Page 53: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Plugin examples – Complex Generators

Adds new Generators with UI. Standard use of the Generator SPI.

Page 54: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Plugin examples – Social Network Analysis

Adds new statistics. Standard use of the Statistics SPI.

Page 55: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Plugin examples – Linkfluence Plugin

Adds new context and global actions in the Data Laboratory. The plug-in has been developed by the Linkfluence company and open-sourced.

Page 56: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Plugin examples – HTTP Graph

Streams the HTTP graph while the user is browsing the web. Implemented as a Generator. It’s a non standard use of the Generator SPI but it works.

Page 57: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Plugin examples – Script console

Adds a Python console as a new component. Doesn’t use a SPI but the plugin uses various APIs.

Page 58: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Plugin examples – Seadragon plugin

Exports the graph from Preview to a zoomable web interface. Extends the Export SPI and uses the Preview API.

Page 59: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Plugin distribution and update

• Plug-ins are available and can be published at http://gephi.org/plugins

• Subscribe to the gephi-plugins mailing-list.

• Plug-ins are also available directly from Gephi’s Plugin Center (Tools > Plugins).

• Like any other module, plug-ins are updated when a new version is available.

Page 60: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Gephi Toolkit

The Gephi Toolkit packages essential modules in a standard Java library. The toolkit is just a single JAR that anyone could reuse in new Java applications, for example:

• Headless Gephi from an input graph file (DOT, GML, GEXF, …) to the resulting PDF, with a list of settings.

• Servlet Use Gephi toolkit to create graph snippets PNG images automatically in a servlet.

The Toolkit is release separately from Gephi and can be download at http:/gephi.org/toolkit

Page 61: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Gephi Toolkit

• The Toolkit is basically Gephi without the user interface modules

• One can find documentation and tutorials on the wiki: Toolkit Portal

• It has a separate Javadoc, as SPI’s implementations are also included

• Plug-ins can also be used in the Toolkit. Consult the wiki

• It’s easy to use from JRuby or Jython

Page 62: Gephi Plugin Developer Workshop

Gephi Plugin Developer Workshop

Thank you! Questions?