Facebook friends network mapping: a Gephi tutorial

Gephi is a powerful social network modelling tool. It also has the great advantage of simplicity: there is no need of any special skills to use it, except curiosity! This tool is used in a large number of contexts, which is why it took us to heart to propose a guide, fit to a wide audience. We offer a tutorial based on your own data from Facebook, which obviously can be used with various kinds of data!

Traduction française

Cliquez ici pour afficher la traduction française !

Table of contents:

1. A short introduction to social network modelling
2. Download data from Facebook
3. Clean the database
4. Getting started with Gephi
5. The practice of visualization
6. Final details
[Bonus 1] Playing with community detection
[Bonus 2] Other examples of graphs made with Gephi

GephiHeader

1. A short introduction to social network modelling

ExampleTo produce a network, two inputs are needed: a list of the actors composing the network, and a list of the relations (the interactions between actors). As part of a mathematical object, actors will then be called nodes, or vertices, and relations will be denoted as edges.

Here, you can observe a very simple graph, with both lists explicited. Two attributes are attached to the nodes : a label (his or her « name ») and his or her gender. In the edge list, « Source » and « Target » entries refer to the nodes’ numeric Id’s.

In our example, the « gender » attribute determines the color of the nodes. The size of a node depends on the value of its « degree » (number of connections).

2. Download data from Facebook

This part is obviously not necessary for those who want to map relational data from a different source.

myfnetworkLaunch the « myfnetwork » application, which lets users map their Facebook ego-centered network (but for an unreadable result…).

myfnetworkapp

click to enlarge

myfnetworkresult

click to enlarge

Fill the form as suggested here (the layout style is not important, in fact) and click on Get picture, giving you this pretty (but useless) visualization of your Facebook network.

myfnetworkdownload

Miraculously (hem well… this is in fact why we have chosen this application), you can see a button letting you download your data! Of course, you should now click on the « Gephi » link, and a .txt file download will start.

3. Clean the database

click to enlarge

click to enlarge

Open your .txt file in a spreadsheet application. The two lists (nodes and edges) appear to be merged into one file, but you can quickly recognize the headings which separate both lists.

click to enlarge

click to enlarge

Copy the node list (generally much shorter than the edge list), and paste it in another file. Then, delete the node list from the original file. We keep only the edges in this one.

click to enlarge

click to enlarge

To secure the compatibility of the data with Gephi, rename the headers of the two files as follows:

- Edges : Source,Target

- Nodes : Id,Label

files

Then save both files as .csv (it should appear as an available option when saving, but if not, save it like you normally do and then rename the extension).

4. Getting started with Gephi

GephiLogo

First of all, downloading and installing the application is very easy: https://gephi.org/users/download/

loading

Our tutorial is based on the 0.8.2 Gephi beta version. If you encounter a problem due to a later update, do not hesitate to let us know.

Now run the application on your computer, and open a « new project » in the start menu.

Import nodes

GephiDataLab

GephiImportIn the »Data Laboratory », click on « Import Spreadsheet » to open the import window.

click to enlarge

click to enlarge

Specify that the separation between your data is expressed by a comma and do not forget to inform Gephi that the data you import is related to nodes, as demonstrated in our example. Then press « next ».

GephiNodes2Finally, fill in the required fields as shown here.

Import Edges

click to enlarge

click to enlarge

Follow the same procedure as for the nodes, but by filling it in the following manner: specify the comma and inform Gephi that this time you import the edges.

GephiEdges2

Fill in the last fields, and uncheck « create missing nodes », because you’ve already imported them.

5. The practice of visualization

GephiOverview

GephiRandomThe action now takes place on the overview panel. The software produces a overview of the graph, spatialized randomly (and pretty illegible).

Eliminate the « noise »

click to enlarge

click to enlarge

The first operation consists in slightly reducing the network to its biggest component (the biggest subset of the network in which we can find, for each couple of nodes, a way from one node to the other). In the right column, select Filters/Library/Topology/Giant Component and confirm by clicking « Filter ».

.

.

Nodes’ size

click to enlarge

click to enlarge

In the « Ranking » panel of the left column (top), select « Nodes » and the « red diamond » (size), then select « Degree » (rolling menu) and enter the minimal and maximal value (we propose 20-200). At that point, click on the « Spline » blue link to edit the shape of the spline (take the 3rd template, as proposed here, in order to consider the surface of the nodes).

Spatialization

click to enlarge

click to enlarge

That’s the main part! While it is possible to play (and lose yourself) with various visualization capabilities, we propose an effective method. Start with Fruchterman Reingold (left column, bottom), and use the same values ​​as in our model (50000; 10; 1).

click to enlarge

click to enlarge

This visualization disposes nodes in a gravitational way (attraction-repulsion, in fact, as magnets). You’re already able to distinguish communities (more densely connected parts of the network). Let the function run until the graph is stabilized.

click to enlarge

click to enlarge

click to enlarge

click to enlarge

Then, we propose to use the Force Atlas 2 (another layout algorithm) to disperse groups and give space around larger nodes. Be careful, the parameters you enter significantly alter the final appearance.

Nodes’ color

click to enlarge

click to enlarge

As there are no categories for the nodes in the database (in our example – point 1 – the nodes had a « gender » parameter), we propose to use once again the « degree » to assign a color to the nodes.

Without changing the « spline », the last used applies. This is not a problem. Feel free and creative.

click to enlarge

click to enlarge

6. Final details

GephiPreview

Go to « preview » for trimming the final details. Unlike during previous stages, changing settings in this menu is reversible, and do not affect the structure of the graph. In the following screenshot, you will find a suggestion of settings for a good rendering :

click to enlarge

click to enlarge

Note that you are free to display (or not) the labels of the nodes, i.e. the names of your facebook contacts.

Export your (art)work

At the bottom of this preview column, you should find an export link. Note that exporting in .png produces figure with a poor resolution. You may want to opt for .svg or .pdf, which have the advantage of being modifiable by your own image/drawing software (we recommend the open source program inkscape for manipulating .svg files).

…and share it !

Do not hesitate to leave us a comment below with a link to access your result! 

The author on Twitter:

Gephi on Twitter:

[BONUS 1] Playing with community detection

click to enlarge

click to enlarge

A network of facebook users – unless you belong to one very closed group – contains internal subdivisions called communities. There are methods that permit to highlight these communities, which depend on the comparison of the densities of edges within a group, and from the group towards the rest of the network. Learn more here!

GephiModularity2In the right column of the « overview » page, click on Statistics/Modularity/Run to display the modularity window. Choose a resolution (between 0.1 and 2), click OK and close it.

GephiModularity3The next step takes place in the Partition menu situated in the left column. Select « Nodes » and « Modularity Class » (rolling menu). You will be then able to modify the colors attributed to the detected communities.

Do not hesitate to repeat this operation with many « Resolutions » ! If you decide to do so, you must deselect and reselect « Modularity Class » in the left column, and refresh color calculation.

For example:

click to enlarge

click to enlarge

[BONUS 2] Other examples of graphs made with Gephi

DataJournalismWhen network analysis helps to investigative journalism

.

JITSOheaderMapping tweets: « just-in time sociology » conference

.

perequationheaderSwiss Financial Equalization 

20 réponses à “Facebook friends network mapping: a Gephi tutorial

  1. Pingback: Cartographie | Pearltrees·

  2. Pingback: RSE | Pearltrees·

  3. Pingback: Experimenting on My Friends | Manuscripts and Machines·

  4. Pingback: GAiA Labs » Graphe d’un réseau Facebook·

  5. Pingback: Pegasus Data | Digital Publishing·

  6. Pingback: Analyser graphiquement son réseau facebook - Martin Grandjean·

  7. Pingback: Gephi Workshop | Studies in Communication and Culture: Data·

  8. Pingback: « VΞillEurs.info 【ツ】 » | [Tutoriel] Récupérer, visualiser & exploiter ses données Twitter (par Pegasus Data Project)·

  9. Pingback: [Tutoriel] Récupérer, visualiser & exploiter ses données Twitter (par Pegasus Data Project) | Veilleurs.info / MIRROR #1·

  10. Pingback: Gaphi | Pearltrees·

  11. Pingback: De quoi parle ma thèse? (2) – Visualisation d’un “réseau” de noms propres | Frédéric Clavert·

  12. Pingback: 2,800 Randon Anons | Neal Rauhauser·

  13. Pingback: List of Bookmarks collected from Jan-May·

  14. Hi, I really like this post, and would like to try it myself. But I’m stuck at importing the nodes and edges. I followed exactly step3, however, the value id and label are not prepopulated in Gephi, instead Gephi created another column that merged everything, hence my edges.csv cannot be imported as the id is different. Do you have any idea on how to fix this? Thanks in advance

  15. Pingback: Scotland’s Collections and the Digital Humanities·

Commenter

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s