last modified: 2017-02-28
Presentation of this tutorial
This tutorial explains how to get and modify Gephi’s source code, and build Gephi from it.
download the source code
run Gephi from the source
modify Gephi’s openGL visualization engine
run Gephi in this modified version
The modified version of Gephi that we will implement will have for effect to add circles around nodes communities.
This project originates from Susie Lu’s creation.
We should get something like:
For this tutorial you will need:
some knowledge of Java.
NetBeans installed (up to date instructions here). Eclipse, IntelliJ or any other code editor won’t do.
a good internet connection since we will download a lot of small dependencies.
no Github account is necessary (if you have one, fork Gephi before doing all the steps below).
Downloading the source code
In NetBeans, go to
Team → Git → Clone
(can’t find this menu in NetBeans? read an alternative just below)
if you already have projects opened in NetBeans, the menu Team → Git → Clone is replaced by:
Team -> Remote -> Clone
Repository URL, put the address of the Gephi repository on Github, which is:
Clone into, select a folder on your disk. No need to create a new folder inside, the cloning process will do it.
Github User and password can be left empty
Then click on
At this step, NetBeans starts downloading the source code of Gephi - not all of it. Should take a couple of minutes, then:
Select (highlight in blue) the line mentioning Gephi, and click on "Open"
You should now see Gephi as a project on the left in NetBeans:
Right click on the project and select "Build with dependencies". This will download all the rest of the source, which can take roughly 5 to 20 minutes.
Running Gephi from source
When the build is complete, expand the folder "Modules" of the Gephi project, and double click on "gephi-app":
This opens a new project on the left of NetBeans, called "gephi-app". This is a submodule of Gephi, dedicated to managing its launch.
And Gephi launches!
Now that we know how to run Gephi from source, we can modify the source and see how it goes.
Modifying Gephi’s openGL visualization engine
We are going to add circles which will enclose groups of nodes (aka communities). In three steps:
Create simple classes for the circles
Add some code in the class which manages the display in OpenGL, so that circles get created
1. Open the
In the gephi project, in the folder Modules, double click on the
2. Create simple classes for the circles
Create a new package and add 3 classes in it:
(I merely adapted these classes from this website)
The code of these classes can be found here.
3. Add the circle creation logic to the class managing the OpenGL display
Open the package
org.gephi.visualization.opengl, and inside open
No need to understand most of the code in this class.
But we see that starting at line 194, a loop on nodes starts:
We will put nodes in a map (declared above, at line 155) where:
keys are the name of the cluster nodes belong too,
values are the Set of Nodes corresponding to the cluster.
(yes, this implies the nodes must have an attribute called "Modularity Class" showing the cluster they belong to)
The code you should add to assign nodes to clusters in the map is in lines 197-203
Then, lines 210-245 iterate on the map, and create the circles around clusters.
The logic of the circle creation in OpenGL can be understood rather easily, by copying and modyfying the code used just above for the creation of nodes, and by looking at the online documentation on how to create shapes in OpenGL.
That’s it. Now just run Gephi from source as we did before. From Gephi, open a network where nodes have a "Modularity Class" attribute, and Gephi will draw circles around nodes from the same clusters: