Visualize Your Social Data Quickly and Easily with Neo4j [Community Post]

[As community content, this post reflects the views and opinions of the particular author and does not necessarily reflect the official stance of Neo4j.]

Connecting your social media accounts with Neo4j is perhaps one of the most exciting ways to visualize your social data.

After all, it’s a great experience to look at the relationships between your liked pages on Facebook or your entire Twitter history and see them all as an interactive graph where you can click and explore each node for more related information.

So, how can you take part in this ultimate social data adventure? In this post, I’ll introduce a simple approach to visualize your Facebook data as an interactive graph.

Just follow these steps to connect your Facebook account with Neo4j and start exploring:

1. Access Your Social Data from Facebook

Go to Facebook Developers and use the Graph API Explorer to generate an access token, after you give the appropriate permissions.

2. Set Up the Environment

Create a new website within Visual Studio in C#. Next, add the following namespaces after the installation of the Neo4j Client in your application. These enable the capabilities of the Cypher query language with Microsoft C# and they also add the Facebook SDK.
Using Facebook,
Using Neo4jClient;
Using Neo4jClient.Cypher;
var client = new FacebookClient(“YourAccessToken”);
dynamic SocialLikes = client.Get(
"me/likes", new { fields = "category, name, created_time, id" });
GraphClient neo4jclient = new GraphClient(
new Uri("https://localhost:7474/db/data"));
neo4jclient.CreateIndex("user", new IndexConfiguration() 
{ Provider = IndexProvider.lucene, Type = IndexType.fulltext }, IndexFor.Node); 

3. Writing Your Cypher Queries

Here’s a simple Cypher query you can use as an example. Feel free to write a different query according to your requirements.

This query displays a graph in which a user and their liked categories are all nodes and the user’s interest areas are the relationships.

Here’s the query in C# within your application:
foreach(likes in SocialLikes)
Neo4j.cypher..Match( "(x:user),(y:category)" )           
.Where( "x.Username='" + facebookUser.Username + "' and	y.Category_name='"
.Create( "(x)-[r:interest_area]->(y)" )

Next, run your application and then move to Neo4j on port 7474 and initialize the graph using following query:
MATCH (X: user)

Now go to your browser tab, and you’ll end up with results similar to what’s pictured below:

Learn How to Quickly and Easily Visualize Your Social Data Using Neo4j

Now just click on the nodes and explore your social graph. Have fun!

For more on graphing your social data, read my full paper A Practical Approach to Process Streaming Data using Graph Database published in the International Journal of Computer Applications.

UPCOMING WEBINAR: Optimizing Data Import: Tips and Tricks

Register for this week’s webinar on 30 July 2015 at 9:00 a.m. Pacific (18:00 CEST) to master the different procedures and tools for a smooth data import process for Neo4j with Senior Engineer, Mark Needham.