I am taking a course on social networks this semester. As our first assignment, the teacher asked us to analyze our Facebook friendship network so we would get used to working with some tools.
If you never heard about social networks as a research topic and have no idea on what “analyze a friendship network” could possibly mean, take a look on this picture:
Here is a small tutorial on how I did my assignment.
First of all, we need to collect the data that will be used on the analysis. There is an app on Facebook that does all the hard work: netvizz. After allowing it to access some of your information, look for a link to a gdf file of your “personal friend network“.
Now that we have our raw data, it is time to get our hands dirty. Download the tool Gephi and import the file you just downloaded. On the import wizard, choose “Graph Type: Undirected“, as Facebook friendships are bidirectional. A very boring representation of your friendship network will appear, but fear not!
At this point it would be a good idea read some of the Gephi documentation. I will quickly report what I did, but by no means you should take it as the best or only way of doing this analysis.
On the right side of the window, there should be a tab called “Statistics“. Run the “Modularity” module (!), to use some bad-ass algorithm to detect communities and the “Avg. Path Length” to find out who plays an important role on your network with respect to connecting different groups. The results of those calculations are stored as attributes on each node (or edge, if it is the case).
The visualization. Part I: Science
Time to make your graph look a little bit better. On the left side of the window, use the “Partition” tab to color the nodes according to its “Modularity Class” and the “Ranking Tab” to change its size according to the “Betweenness centrality“.
If you are lucky, you should have something that looks like this:
The visualization. Part 2: Art
So far, things were pretty straightforward. Click here, press this, and so on. Now it is time to unleash your artistic side. Also on the left side, under “Layout“, there are different algorithms that will make your nodes literally dance on your screen. Play with all of them until you get something you like, and don’t forget to use the “Random Layout” as a mean of resetting your work.
After you get something nice, you can also use tools to manually move nodes on your graph. There is also a tool to inspect nodes, so you can see the name of the person represented by a specific node. In case you want to show those names on the graph, there is a button on the lower toolbar for that. Moreover, this page teaches you how to show labels only on some filtered nodes.
The gran finale
So far you have been on the Overview mode, which allows you to edit your graph. There is also a Preview mode which lets you export your beautiful graph to an image file.
Here is what I got:
The name of the communities (in Portuguese, sorry), were added manually by me on a image editing software.
This graph allows you to easily identify communities among your friendships and see people that play a key role by connecting different communities.
Bonus: interactive graph on the web
On my first attempt to make it work, Gephi (version 0.8.2) did not add an id to the edges on the exported gexf file, and sigma.js did not like that. To fix this issue, I wrote a small ruby snippet to insert unique id’s on all edges. The source code is on GitHub.
The complete integration with sigma.js can be found on a JsFiddle, embedded below (may take some time to load). And yes, I also noticed some encoding problems on the labels.