Twitter Graph

Show data from your personal Twitter account

The Graph Your Network application inserts your Twitter activity into Neo4j.

Here is a data model of the graph:

Twitter Graph

Show data from your personal Twitter account

The Graph Your Network application inserts your Twitter activity into Neo4j.

This application allows you to query things like:

  1. Who's mentioning you on Twitter
  2. Who are your most influential followers?
  3. What tags you use frequently
  4. How many people you follow also follow you back
  5. People tweeting about you, but you don't follow
  6. Links from intresting retweets
  7. Other people tweeting with some of your top hashtags
Twitter Graph

Your mentions

To the right is a giant code block containing a single Cypher query statement to determine who's mentioning you on Twitter.

  1. Click on the code blocks
  2. Notice they get copied to the editor above ↑
  3. Click the editor's play button to execute
  4. Wait for the query to finish
Graph of some of your mentions
// Graph of some of your mentions
MATCH
  (u:Me:User)-[p:POSTS]->(t:Tweet)-[:MENTIONS]->(m:User)
WITH
  u,p,t,m, COUNT(m.screen_name) AS count
ORDER BY 
  count DESC
RETURN
  u,p,t,m
LIMIT 10
Details as a table
// Detailed table of some of your mentions
MATCH
  (u:User:Me)-[:POSTS]->(t:Tweet)-[:MENTIONS]->(m:User)
RETURN
  m.screen_name AS screen_name, COUNT(m.screen_name) AS count 
ORDER BY 
  count DESC
LIMIT 10
Twitter Graph

Most Influential Followers

Who are your most influential followers?

  1. Click on the code block
  2. Notice it gets copied to the editor above ↑
  3. Click the editor's play button to execute
  4. Wait for the query to finish
// Most influential followers
MATCH 
  (follower:User)-[:FOLLOWS]->(u:User:Me)
RETURN 
  follower.screen_name AS user, follower.followers AS followers
ORDER BY
  followers DESC
LIMIT 10
Twitter Graph

Most Tagged

What hashtags have you used most often?

  1. Click on the code block
  2. Notice it gets copied to the editor above ↑
  3. Click the editor's play button to execute
  4. Wait for the query to finish
// The hashtags you have used most often
MATCH
  (h:Hashtag)<-[:TAGS]-(t:Tweet)<-[:POSTS]-(u:User:Me)
WITH 
  h, COUNT(h) AS Hashtags
ORDER BY 
  Hashtags DESC
LIMIT 10
RETURN 
  h.name, Hashtags
Twitter Graph

Followback Rate

At what rate do people you follow also follow you back?

  1. Click on the code block
  2. Notice it gets copied to the editor above ↑
  3. Click the editor's play button to execute
  4. Wait for the query to finish
// Followback rate
MATCH 
  (me:User:Me)-[:FOLLOWS]->(f)
WITH 
  me, f, size((f)-[:FOLLOWS]->(me)) as doesFollowBack
RETURN
  SUM(doesFollowBack) / toFloat(COUNT(f))  AS followBackRate
Twitter Graph

Follower Recommendations

Who tweets about you, but you do not follow?

  1. Click on the code block
  2. Notice it gets copied to the editor above ↑
  3. Click the editor's play button to execute
  4. Wait for the query to finish
// Follower Recommendations - tweeting about you, but you don't follow
MATCH 
  (ou:User)-[:POSTS]->(t:Tweet)-[mt:MENTIONS]->(me:User:Me)
WITH 
  DISTINCT ou, me
WHERE
  (ou)-[:FOLLOWS]->(me)
  AND NOT 
    (me)-[:FOLLOWS]->(ou)
RETURN 
  ou.screen_name
Twitter Graph

Links from interesting retweets

What links do you retweet, and how often are they favorited?

  1. Click on the code block
  2. Notice it gets copied to the editor above ↑
  3. Click the editor's play button to execute
  4. Wait for the query to finish
// Links from interesting retweets
MATCH
  (:User:Me)-[:POSTS]->
  (t:Tweet)-[:RETWEETS]->(rt)-[:CONTAINS]->(link:Link)
RETURN
  t.id_str AS tweet, link.url AS url, rt.favorites AS favorites
ORDER BY
  favorites DESC
LIMIT 10
Twitter Graph

Common Hashtags

What users tweet with some of your top hashtags?

  1. Click on the code block
  2. Notice it gets copied to the editor above ↑
  3. Click the editor's play button to execute
  4. Wait for the query to finish
// Users tweeting with your top hashtags
MATCH
  (me:User:Me)-[:POSTS]->(tweet:Tweet)-[:TAGS]->(ht)
MATCH
  (ht)<-[:TAGS]-(tweet2:Tweet)<-[:POSTS]-(sugg:User)
WHERE
  sugg <> me
  AND NOT
  (tweet2)-[:RETWEETS]->(tweet)
WITH
  sugg, collect(distinct(ht)) as tags
RETURN
  sugg.screen_name as friend, size(tags) as common
ORDER BY
  common DESC
LIMIT 20

More code