Visualizing Friendships

by Paul Butler on Monday, December 13, 2010 at 5:16pm ·

Visualizing data is like photography. Instead of starting with a blank canvas, you manipulate the lens used to present the data from a certain angle.

 

When the data is the social graph of 500 million people, there are a lot of lenses through which you can view it. One that piqued my curiosity was the locality of friendship. I was interested in seeing how geography and political borders affected where people lived relative to their friends. I wanted a visualization that would show which cities had a lot of friendships between them.

 

I began by taking a sample of about ten million pairs of friends from Apache Hive, our data warehouse. I combined that data with each user's current city and summed the number of friends between each pair of cities. Then I merged the data with the longitude and latitude of each city.

 

At that point, I began exploring it in R, an open-source statistics environment. As a sanity check, I plotted points at some of the latitude and longitude coordinates. To my relief, what I saw was roughly an outline of the world. Next I erased the dots and plotted lines between the points. After a few minutes of rendering, a big white blob appeared in the center of the map. Some of the outer edges of the blob vaguely resembled the continents, but it was clear that I had too much data to get interesting results just by drawing lines. I thought that making the lines semi-transparent would do the trick, but I quickly realized that my graphing environment couldn't handle enough shades of color for it to work the way I wanted.

 

Instead I found a way to simulate the effect I wanted. I defined weights for each pair of cities as a function of the Euclidean distance between them and the number of friends between them. Then I plotted lines between the pairs by weight, so that pairs of cities with the most friendships between them were drawn on top of the others. I used a color ramp from black to blue to white, with each line's color depending on its weight. I also transformed some of the lines to wrap around the image, rather than spanning more than halfway around the world.

 

View high-res (3.8MB)

 

After a few minutes of rendering, the new plot appeared, and I was a bit taken aback by what I saw. The blob had turned into a surprisingly detailed map of the world. Not only were continents visible, certain international borders were apparent as well. What really struck me, though, was knowing that the lines didn't represent coasts or rivers or political borders, but real human relationships. Each line might represent a friendship made while travelling, a family member abroad, or an old college friend pulled away by the various forces of life.

 

Later I replaced the lines with great circle arcs, which are the shortest routes between two points on the Earth. Because the Earth is a sphere, these are often not straight lines on the projection.

 

When I shared the image with others within Facebook, it resonated with many people. It's not just a pretty picture, it's a reaffirmation of the impact we have in connecting people, even across oceans and borders.

 

Paul is an intern on Facebook’s data infrastructure engineering team.


· Comment · Share
  • Misbah Khan, 김진태, Stefan Walter Moeller and 2,826 others like this.
  • 272 shares272 shares
    • Medea Metreveli Does FB haev an updated version of this map? I would like to use this info for promoting the use of social media in Africa. Thank you
      December 19, 2011 at 6:32am
    • Florian Rhymer hehe - i knew the picture but just now read you did it with R and euc distances. elegant one
      December 20, 2011 at 3:55pm
    • Yang Yu china, where you are!
      December 21, 2011 at 1:11pm · 1
    • Mehdi Maghsoodnia Paul, great data music composition.
      December 21, 2011 at 10:25pm · 1
    • Allen Lee 期待中国。。
      December 23, 2011 at 5:29am
    • Nicolas Loubet Wow.
      December 26, 2011 at 5:52pm
    • Karl Brix Zinglersen Impressing, that Greenland is so visible - only c. 50K people distributed across very small towns and settlement. FB is the prominent social tool in Greenland.
      December 28, 2011 at 5:15am · 2
    • Roberto Franco hola
      December 29, 2011 at 3:47pm
    • Michael Yeoh nice!
      December 30, 2011 at 12:56am · 4
    • Leo Lahti Cool. Could you provide a link to the source code?
      January 2 at 12:58am
    • Emmanuel Moulton hi girl are u on line now?
      January 3 at 3:01pm · 1
    • Emmanuel Moulton true love is what on my mind
      January 3 at 3:03pm · 1
    • Arnaud Verchere Do you have an update now that you have more than 700 Million? I'd really like to see the impact of FB on the Arab Spring.
      January 3 at 10:26pm · 1
    • Abdelkader Dahmane السلام عليكم يا اهل السنة والجماعة
      January 8 at 4:43am · 2
    • Abulrehman Moh M iluminate wake UPPP people
      January 8 at 8:35am · 2
    • Comm Dept I'd like very much to use this for our Department Of Communication at Georgia State University. It's such an amazing way to represent communication. Would that be ok? We'd be sure to give you full credit of course. Thanks.
      January 10 at 4:58pm
    • Sir-William Edward Belinski only the civilized world is lit up
      January 11 at 11:43am · 2
    • Vee Edwards Paul, how can we map our own FB friendship map? It would be great if you'd develop an app for that!
      January 14 at 5:22pm · 3
    • Selma Kuru Aslan Paul, how can use it ?
      January 18 at 2:19am
    • Diamal le Silensieux yes how can i use itt
      January 18 at 4:09am
    • Jared Jackson Way cool
      January 18 at 6:20am
    • Nanuka Absandze SHEGECI
      January 18 at 8:03am
    • Paul Monllau Grima muy bueno !! saludos desde argentina !
      January 19 at 1:33pm
    • Weniweni Mostwanted Thom Sitima mafana nonse mwandilira am crazy at this college hate it or like it am fli
      January 20 at 2:40am
    • Kanij Fatema I Love My vilej
      January 20 at 9:48pm · 2
    • Mahmuda Akter Shurovi hmmmm
      January 25 at 9:48am · 1
    • YungChang Wang Really fantastic villa... Thanks...
      January 28 at 3:49am
    • Murad Mahmudov emen istgyirem ki map seh feme qoyum
      February 1 at 2:25am · 1
    • Abraham Sunday I LOVE THIS
      February 3 at 12:23pm
    • Shahebji Rathod nice
      February 3 at 7:25pm
    • Venkat N. Venkatraman is there an updated map circa December 2011?
      February 7 at 12:05pm
    • Thomas Spitzer COOL - any live update that we can see??
      February 8 at 7:52am
    • Marilyn McCartney Botzenhart Magnificent!
      February 12 at 3:02am
    • Pitso Kgodumo PURE GRANDIOSITY
      February 13 at 3:46am
    • Dave Kosanke Paul, how can I use this image legally in our company literature, etc? Please advise. thanks!
      February 14 at 11:42am
    • Ni Po I would like to go to all the "dark" parts of the map...
      February 16 at 9:09am
    • Vikas Goyal China and Australia do not seem to be a part of the Facebook world ??
      February 17 at 4:20am
    • Benito Lozano f,bok,tiene,demaciado,que,ofrecer,que,me,vuelve,loco
      February 19 at 6:30pm
    • Patricia Rowe this looks a lot like thought fields
      Monday at 6:44am
    • Steve Longpre Paul...any chance this could be used as an app to create a "friendship map" showing how potential friends connect to ones existing friends list? It'd be neat to visually see how we all connect to one another...the old 6 degrees thing.
      17 hours ago
    • Yoshihito Niimura It is quite impressive that Indonesia have so many Facebook users. On the other hand, as for Japan, Hokkaido and Tohoku is almost missing...
      about an hour ago