---
layout: post.liquid
title: Facebook Graph Theory
published_date: 2007-06-28 11:54:00 -0700
data:
nolist: true
---
After the AP test, all I had left to do in Calculus BC was to give a presentation at the end of the year on some mathematical topic. I have always been interested in graph theory, and my partner thought it was an ok idea. Then I had to find some way to make this abstract subject tangible to my peers (the people doing pi had it easy; all they did was give everyone some pie).
Just about everyone at Mountain View High School is in a social network. 15 of the 20 people in our Calculus class are in Facebook. So I wrote a few tools to pull the data out of Facebook and make some pretty graphs. Implementation details after the pictures.
This is a graph of the people in my Calculus class. Nothing that interesting going on here.
TODO 2020: find old image.
My cousin Chris went to Bellarmine while I went to Mountain View. Our mutual friend T.J. went to Bellarmine for two years and then Mountain View for two. Below is Chris's graph. People who go to Mountain View are in blue. You can see T. J. is better connected to Chris's friends than my group of friends.
TODO 2020: find old image.
Implementation Details
To get a social graph, I used the FQL statement shown below (replace {0} with the current user's uid). Microsoft's Facebook Developer Toolkit made it pretty easily to talk to the Facebook rest service.
I wrote a small Visual Basic app that generates a graph definition file to feed into Graphviz. I ran neato, twopi, and fdp and chose the best looking graph.SELECT uid1, uid2 FROM friend where uid1 in (select uid2 from friend where uid1 = {0}) and uid2 in (select uid2 from friend where uid1 = {0})