So it’s my first week in the Social Network Analysis and my 4th week in Programming in Scala by Martin Odersky which are both available as online courses in coursera. I’ve tried enrolling to several online courses before but I never finish a single one because of several factors: being so lazy to work on assignments, day job, personal projects. So hopefully, I can finish at least one of them :)
The photo above is a graph of my Facebook friends, obviously anonymized to keep their names private :). This is actually the first homework in the SNA course in which we need to use either the instructor’s Facebook data or we can use our own. So I went to http://snacourse.com/getnet, I checked all the checkboxes there and downloaded the GML. GML is just one of the formats supported by Gephi - an open-source application that we need to use to visualize the data.
Installing Gephi on Mac
You can download the latest version of Gephi from https://gephi.org/ which is 0.8.2 Beta as of this writing but for Mac users, if 0.8.2 won’t work for you, try the older version 0.8.1 Beta. The latest version seems to have issues with Java 7.
After installing Gephi, we can now load the Facebook GML file that we downloaded by simply going to File > Open.
Just leave everything as default and click on OK. The graph will be rendered in the middle screen and you’ll be able to see something like this:
In order for us to be able to visualize it properly, we need to select the layout algorithm and according to the course instructor, her favorite is the Force Atlas 2 so we’ll select Force Atlas 2 in the Layout tab which can be located in the lower left hand side of the the Gephi screen.
Check the Dissuade Hubs and Prevent Overlap so that the nodes will not be drawn on top of each other giving us a clear overview of their relationship with each other. Also, set the Gravity to 30 to keep things close to each other because in my case, I have lots of disconnected components or those who doesn’t have any common friends with me and we don’t want them to be drawn too far away from the center of the graph.
Click Run and then you’ll see a nice animation of graph and eventually you’ll notice some communities or groups being formed.
Next step is to make the graph a bit more interesting by changing the colors and the size of the nodes according to its degree. Degree refers to how many connections are connected to the node and it can be Indegree or Outdegree but in our case, we have an undirected graph so it doesn’t really matter.
We do this by going into the Ranking tab in the upper left hand side of the screen.
Select Degree from the dropdown and specify the color range for the nodes. 0 degree will have the left-most color and the highest degree will have the right-most color.
Now select the diamond icon also in the same tab. This screen allows us to change the size of the node depending on its degree.
Set the min size to 5.5 and max size to 20 then click Apply. You’ll see the large red dot in the middle of the graph which represents the node with the highest degree or the person whom I have lots of common friends which happened to be my wife :)