In this tutorial, we will try the most popular tools for graph exploration in Gephi. We will learn how to get visual insights by spatializing and highlighting important attributes of graphs. As an example, we will use a subnetwork of Wikipedia pages that had anomalous visitor activity over the period 15-31 October 2018. You can find the corresponding .gexf
file in this folder.
Before starting this tutorial, install the following plugins (unless they are already installed):
- Multigravity Force Atlas 2
- Circle Pack layout
- Leiden algorithm
- Bridging centrality
- Clustering coefficient
Watch a short walk-through screencast to get an idea of what we are going to do in this tutorial. Attention: the video has sound.
To start with, let's spatialize our graph. To do that, we can use force-directed layouts. They don't require any attributes and quite easy to setup. We will try four layouts: Multigravity Force Atlas 2, Yuifan Hu, Fruchterman-Reingold, Open Ord. You can find all these layouts in the "Layout" pane. Here are some tips related to the parameters of each algorithm:
- Parameters
- Multigravity Force Atlas 2
- Scaling. Control scale of the expansion of the graph.
- Dissuade hubs. Apply stronger repulsive forces to hubs.
- Prevent overlap. Prevent nodes from overlapping.
- Yifan Hu
- Step ratio. High ratio improves quality (at the expense of speed)
- Optimal distance. Controls distance between nodes
- Theta. Smaller Theta gives leads to more accurate results (slower)
- Fruchterman-Reingold (expensive)
- Gravity. Attraction strength.
- Speed. A tradeoff between speed and accuracy. Higher values lead to faster but less accurate results
- Open Ord
- Edge Cut (0 to 1). Higher values lead to more clustered results.
- Num Iterations. Higher values lead to larger expansion.
- Multigravity Force Atlas 2
In the following examples, colors correspond to modularity.
Multigravity Force Atlas 2 | Yifan Hu | Fruchterman-Reingold | Open Ord |
---|---|---|---|
![]() ![]() |
![]() ![]() |
![]() ![]() |
![]() ![]() |
With Gephi, we can highlight attributes of the nodes using different colors and sizes, reflecting the scale of the attributes. You can do it using "Appearance" pane. Before using the attributes, we should compute them using "Statistics" pane.
Some examples of attributes that can be used for sizing and coloring are listed below.
We can use the size to highlight local attributes of nodes.
- Degree. Connectivity of a node
- Centrality
- Betweenness. Number of random walks passing through the node
- Bridging. A measure of bi-partisanship of a node. Nodes that connect multiple communities (serve as bridges) have high bridging centrality
- Page rank. Importance of a node
- Local clustering coefficient. Determines how close are neighbors of a node to a complete graph
Coloring different communities of the graph is a allows to explore the structure of your graph and make it more visually appealing. To do that, we need to run a community detection algorithm. Once you compute communities, you can color the graph using "Appearance" pane.
- Community detection algorithms
- Louvain modularity (Modularity in Gephi)
- Leiden algorithm
Gephi also provides a set of attributed layouts. You can use them to spatialize nodes according to their attributes. Here are a few examples of attributed layouts:
- Circular. We can use it to show the distribution of nodes and their links and order nodes by an attribute and draw them on a circle.
- Radial Axis. This layout allows studying homophily by showing distributions of nodes inside groups. Axes radiate from the central circle. The layout groups nodes by an attribute and draw them in axes.
- Network splitter 3D. Use this if you want to unfold the graph in layers based on attributes. However, there is a trick. To use it, you need to copy a column with an attribute of interest and add [Z] in the end of the name of the column. Z-maximum level parameter should be equal to the number of layers you want to get, e.g. number of communities if you use communities as a splitting attribute.
- Circle pack. This layout allows to group nodes by attribute(s) and plotting them in circles.
In the examples below, we use modularity as an attribute.
Circular | Radial Axis | Network splitter 3D | Circle pack |
---|---|---|---|
![]() |
![]() |
![]() |
![]() |
Normally, after all the transformations we have performed, it's hard to read labels. To enhance readability and interpretability of your graph, use the following layouts.
- Expansion/Contraction. This layout simply changes the scale of the graph.
- Noverlap. Use it to prevent overlap of nodes.
- Label adjust. This layout spatializes labels so that they are easier to read. Before running it, you should display labels.
If you want to learn how to publish Gephi graphs online, take a look at this tutorial.
For more information, check out official Gephi tutorials:
- Gephi tutorial on layouts.
- Other Gephi tutorials.