last modified: 2017-02-19
This project is for complete beginners to Gephi. It supposes you have Gephi installed and running on your computer. That is all.
When finishing this tutorial, you should be able to:
be familiar with the vocabulary to discuss networks
download a network file for this exercise
description of the file / the network == !
open a network file
read the report after opening a file
show the labels of the nodes
layout the network == !
visualize attributes of the network
prettify the network for enhanced readability
compute the centrality of the nodes in the network
visualize attributes created by Gephi
export a visualization as a picture or pdf
download this zip file and unzip it on your computer.
You should find the file
miserables.gexf in it.
Save it in a folder you will remember (or create a folder specially for this small project).
This file contains a network representing "who appears next to whom" in the 19th century novel Les Misérables by Victor Hugo.
A link between characters A and B means they appeared on the same page or paragraph in the novel.
The file name ends with ".gexf", which just means this is a text file where the network information is stored (name of the characters, their relations, etc.), following some conventions.
open Gephi. On the Welcome screen that appears, click on
Open Graph File
miserables.gexf on your computer and open it
A report window will open, giving you basic info on the network you opened:
This tells you that the network comprises 74 characters, connected by 248 links.
Links are undirected, meaning that if A is connected to B, then it is the same as B connected to A.
The report also tells us the graph is not dynamic: it means there is no evolution or chronology, it won’t "move in time".
OK to see the graph in Gephi.
This is how the network appears in Gephi. Not very useful! Let’s examine what we have here.
Gephi has 3 main screens:
Overview: where we can explore the graph visually
Data Laboratory: provides an "Excel" table view of the data in network
Preview: where we polish the visualization before exporting it as a pictue or pdf
What we see here is the Overview.
In the Overview, the graph is shown at the center. Around it, several panels help us fine tune the visualization.
"Filters", where we can hide different parts of the network under a variety of conditions
"Statistics", where we can compute metrics on the network
"Appearance", where we can change colors and sizes in interesting ways
"Layouts", where we can apply automated procedures to change the position of the network
A series of icons to add / colorize nodes and links manually, by clicking on them
Options and sliders to change the size of all nodes, links, or labels
More options become visible if we click on this little arrow head pointing up
A network consists in entities and their relations. This is what we just visualized. Yet, the properties of these entities remain invisible.
For instance: the characters in the novel "Les Misérables" are male or female. Are males more likely to be connected to males, or females? Just looking at the network in Gephi, we can’t tell.
Now, we will see how to make this property ("Gender") visible.
We will color the nodes based on their gender. To do that, we select
Gender in the
There are a number of issues with the result we get:
the network is too big or too small, it is hard to read
the labels of the characters overlap
the size of the labels might be too big / small
the links are sometimes too large
Let’s fix these issues.
either we use the "scaling" parameter of the layout, as we have seen here.
or the scale is fine, it is just that we need to zoom it or out. Use the scrolling wheel of your mouse, and right click to move the network.
In the layout panel, choose "Label Adjust" or "Noverlap": these layouts will move the nodes just so that the Labels stop overlapping:
Don’t forget to click on "Run" to apply these layouts.
Open the bottom panel of Gephi by clicking on tiny arrow head (1). Then select "nodes" (2), then move the slider (3).
"Centrality" is a very good metrics to first get an idea of a network. What does centrality mean? Intuitively, we understand that a "central" node will probably sit in the middle of the network. But how to measure that "scientifically", so that we have an objective confirmation of our visual impression?
There are several ways, all equally interesting.
We can measure
degree centrality. "Degree" is the technical term for "number of connections that a node has".
degree centrality just means that the most central node is the node which has the most connections. Simple!
Another measure is
betweenness centrality. This one is more tricky.
First, you have to imagine what is a
path from node A to node B is a chain of nodes, the road if you will, that you have to traverse to go from A to B.
shortest path from A to B is the quickest road from A to B: the path that has the smallest number of nodes between A and B.
A node which is on many shortest paths is "between" many nodes. And when you realize it, it is a very intuitive sense of what it means to "be central". These nodes have a high
Gephi computes it for you. Find "Network diameter" in the statistics panel and click "run":
This will open a window with parameters (explained in a more advanced tutorials). Click "OK":
A report window opens (also explained in a other tutorials). Close it.
Now we can visualize this information.
Gephi has computed for us the betweenness centrality of all nodes. This remains invisible on the network, however.
It would be interesting to, say, resize the nodes according to their centrality: the more central a node, the bigger. This would allow for a very quick visual appreciation of which nodes are the most central.
First, let’s switch to the data laboratory to see how Gephi stored the "betweenness centrality" of each node:
When we ran "Network Diameter" in the statistics panel, Gephi has actually computed many kinds of centralities (not just "betweenness centrality"):
To resize the nodes according to the value of their betweenness centrality, we use the
|make sure you select the correct options|
Select the maximum value for anti-aliasing, and multiply values for width and height for higher resolution. For example, resolution x 3 is width = 3072 and height = 2304
Let’s switch to the preview panel:
The preview panel is dedicated to the preparation of the picture to be exported as a pdf or svg, which are "scalable": in pdf or sv, the resolution of the graph will remain perfect, even with a strong zoom. But as you see, it means the network is now looking different than in the Overview.
|contrary to the Overview panel, here you need to hit the "refresh" button after each parameter change.|
Here I change just 2 parameters:
Show Labels and
Font (which I reduce to size "5"), to get:
Export: just click on the button and select the file format you prefer
download this zip file if you need to see the network in its final form.
Visit the Gephi group on Facebook to get help,
or visit the website for more tutorials
Our network of Les Miserables characters was undirected. Can you think of networks which are directed?
Imagine how undirected and directed networks differ when computing centrality, for example.
Force Atlas 2 is a layout which brings together connected nodes, and spreads out unconnected nodes. We might have nodes with no relation at all with other nodes (called "isolated nodes").
How will these isolated nodes move on screen?
When applying the Force Atlas 2 layout, the network moves quickly, then stabilizes, and then keeps moving a bit.
Can you guess why this is happening?
In the list of layouts, Force Atlas 2 is just one of many options you can choose. Try "Fruchterman Reingold" and "Yfan Hu".
These are layouts which follow the same logic as Force Atlas 2, but with slight variations. Explore how these algorithms result in similar, yet specific layouts.
In this tutorial, we defined degree centrality. Can you imagine a situation when a node with the largest degree centrality will actually be in the periphery of the network? You can draw a toy network to help you figure.