Archive for the ‘Social Network Analysis’ Category

My Social Network

Sunday, October 13th, 2013

I was playing around with Gephi, and I loaded my Facebook data to visualize my social network (or at least my Facebook social network). This is the result (click for full size).

 SocialNetwork

As you can see the network is pretty modular, which is to be expected since I’ve lived in 6 cities. There are 13 communities:

  1. High School, mostly my graduating class (21.97%) – Green
  2. The rest of Monterrey (17.41%) – Red
  3. ITP (16.4%) – Acqua
  4. Model UN (14.23%) – Light Blue
  5. UT Austin (12.57%) – Fuchsia?
  6. Oklahoma City (5.71%) – Purple
  7. Family, extended family, and family friends (5.13%) – Dark purple
  8. Schlumberger (3.32%) – Lime Green
  9. GovLab (1.3%) – Yellow
  10. NYCDigital (0.79%) – Orange
  11. Students For Sensible Drug Policy (0.72%) – Dark Blue
  12. Las Chilangas de Nueva York (0.22%) – Dark Blue inside ITP blob
  13. The group of Canadians I randomly befriended on a bus one day. (0.22%) – Tiny Light Green Offshoot from large Green blob

I filtered out those nodes which had less than 2 degrees (less than 2 mutual friends), but it was interesting to see the lonely nodes on my network. Those are mostly people that I have encountered while traveling alone or have randomly met. The graph contains 1,384 nodes (friends) with 35,226 edges (connections) between them. The longest path (network diameter) between two of my friends (without going through me) is 8. The huge blue dot in the middle is Gaby, and she is connected to 7 of my 13 communities and shares friends. In second place is Chantel who knows everyone in Monterrey.

Making your own graph

If you want to do this for your own Facebook data, go to http://snacourse.com/getnet. Authorize the app. I selected all options in case I want to use that data later. Click on the ‘click here‘ link in Step 2. The app will need to scrape your Facebook and this might take a while if you have a large network.

You’ll also need to download Gephi, an open source visualization software.

Once you’ve downloaded your data and Gephi, open Gephi and File->Open your data file (default settings should be OK). You’ll see a bunch of dots arranged in a square in the middle of the screen.

Screen Shot 2013-10-13 at 12.04.02 PM

You’ll need to tell Gephi to reorganize the graph. On the bottom left you can choose a Layout. I chose ForceAtlas 2, checked Dissuade Hubs and Prevent Overlap, and set Gravity to 50.

Click Run. You’ll see the dots start to move around. Depending on the size of your network, it might take a while before you start seeing a discernible pattern. You can click on an individual node to find information about it by selecting the Edit tool in the toolbar (bottom-most tool). The node info will be displayed on the edit tab next to the Partition and Ranking tabs.

Screen Shot 2013-10-13 at 12.19.17 PM

If you want to remove the lone nodes and just show your one giant network, on the right of your screen you’ll see a Statistics and Filters tab. Click on Filter -> Topology, and drag “Giant Component” below to where it says ‘Drag filter here‘. Click Filter at the bottom. I also filtered out nodes with less than 2 degrees. Drag ‘Degree Range‘ into your Queries as well. When selected, you’ll see Degree Range Settings at the bottom. Drag the sliders or double-click the numbers to edit them. (Don’t click Filter again, the button works like an On/Off switch, and it was already on from the previous step).

Degrees

Before sizing the nodes by degree (in this case degrees represents mutual friends), let’s calculate the Average Degree. Under Statistics, click on Run next to Average Degree. You’ll get a result for average number of mutual friends across your network and you’ll get a nifty distribution graph. Usually this looks like a power-law distribution.

Now, go to the top left and click on the Ranking tab. In the drop down menu, select Degree. You can visualize with color, size, label color, or label size. I chose Size, but feel free to play around. Choose a range that fits best for your network, and hit Apply.

Screen Shot 2013-10-13 at 12.15.41 PM

By the way, if you graph isn’t changing much anymore, you can stop the ForceAtlas 2 Layout process. Click on Stop. The dots should stop moving.

Communities / Modularity

To color the different communities, you’ll need to calculate Modularity. It’s under the Statistics tab on the right. Click Run. Press OK for the default settings. Again, you’ll get a nifty distribution chart.

Go to the Partition tab on the top left. Under Nodes, click the Refresh Button Screen Shot 2013-10-13 at 12.27.49 PM. Select Modularity Class from the drop-down menu. If you don’t like the colors, you can right-click inside that window and select Randomize Colors. Or click on the individual colors and manually select your colors. Once you’re happy with the colors, click Apply.

Awesome! You’re own social network graph. Gephi is a lot of fun to play around, and I encourage you to do so. The Gephi website has a bunch of tutorials you can follow that will teach you some of the awesome things you can do. To save your graph as a PDF, click on Preview on the top-top left. Feel free to play around with the settings, they’re pretty straight forward. When you’re done, just click on Export SVG/PDF/PNG at the bottom left.

I’ll try to make my graph prettier. As soon as I can get Illustrator to open up this tiny file.