A simple project with Gephi

Gönül Aycı, PhD
3 min readOct 2, 2017

--

I am working on a project that involves understanding relationships between domain specific Twitter users. When we query Twitter for such users we end up with far too many users to comprehend, which is why visualizing them is very useful. Fortunately, Gephi, an open source tool for analyzing and visualizing graphs, comes to our rescue.

You can download Gephi for Windows, Mac OS X, and Linux. I used the Quickstart tutorial. Here, I will show how I use Gephi to visualize Twitter users. I create a graph from users fetched from Twitter based on a query, where users are nodes and edges represent the friend relationship. The size of the nodes depends on their in-degree.

In order to import a graph to Gephi, it must be appropriately formatted. Gephi supports GEXF, GraphML, Pajek NET GDF, GML, TLP Tulip, CSV, and. zip compressed are accepted formats. Here, I will explain how to use comma separated values (CSV) by creating two files, one for the nodes and the other for the edges as shown below:

Two node lists: the one on the left is unweighted and the one on the right is weighted

The Node ID and Label columns must be on the node list. I used Twitter screen name as the node label and the follower count as the Weight.

Edge list

The edge list specifies Source and Target nodes. As you can see, these are the user ids from the first column of the node list. Then we need to import these files into Gephi. Note that the second file that is imported must be appended to the same workspace as shown below:

At this point we see information about the nodes and edges we just imported. Now, it is time to focus on the visualization. Gephi offers several Layout algorithms. Here I show the customization I did for the Force Atlas algorithm. First, I chose Nodes → Ranking from the Appearance tab to adjust the size and color of the node to be larger and darker with higher weight.

To show the node labels, we need to click on the black T.

Finally, we can see the resulting graph by clicking on the Preview tab. The appearance can be changed by playing the Settings section on the left. This graph can be exported into the SVG / PDF / PNG formats. Here is my export!

We can see in this community anasebrahem is the most followed user on Twitter.

As we show above, we can also create a graph by degrees of nodes. This is another analyzing technique. We can choose one of them depends on our problem.

All the best.

--

--

Gönül Aycı, PhD
Gönül Aycı, PhD

Written by Gönül Aycı, PhD

Write about topics that inspire me on ML and AI. A passionate advocate for women in technology. Pythonista

No responses yet