Extracting Your LinkedIn Connections Into Neo4j Graph Database
Today I was playing with exploring my LinkedIn network – just for fun and as a pretext to play with Neo4j.
I’ve managed to ask simple questions like “With whom do I have the most contacts in common?” or “What is the most popular first name in my network?” (Piotr & Marcin)
Challange #1 – How to get the data?
I have decided to use inmaps from Linkedin. Below you can see screenshot of my network:
By using Chrome Developer Tools you can see Network traffic made by inmaps. There are 2 interesting resources for us:
MATCH (user)-[r]-(friend)
WITH user, count(friend) AS friends
ORDER BY friends DESC
WHERE friends > 90
RETURN user.firstname, user.lastname, user.headline, friends
What is the most popular first name in my network?
12345678
MATCH (user)
WITH user.firstname as firstname,
collect(DISTINCT user.lastname) as lastnames,
count(DISTINCT user.lastname) as c
ORDER BY c DESC
RETURN firstname, lastnames, c
("Piotr", "Marcin", "Pawel", "Anna", "Paul", "Lukasz")
What are the most popular headlines in my network?
123456789
MATCH (user)
WITH left(upper(trim(user.headline)), 12) as headline,
collect(DISTINCT (user.firstname + user.lastname)) as names,
count(DISTINCT (user.firstname + user.lastname)) as c
ORDER BY c DESC
RETURN headline, names, c
("RECRUITMENT", "SOFTWARE DEV", "SOFTWARE ENG")