Graph Analytics:
Data is great, but true insight comes from examining relationships between data points. Hiding somewhere in your data are patterns of relationships representing money on left on the table – if only they could be discovered. Some companies use graphs to efficiently compute recommendations, organize social networks, manage master data, optimize marketing and detect fraud – complex pattern analyses simply not possible in SQL databases. This ability to quickly extract patterns from massive amounts of data is why graph databases are at the forefront of enterprise analytics. There are a number of graph databases, but I am using neo4j
Neo4j:
Neo4j is a highly scalable, native graph database that leverages data relationships as first-class entities. NoSQL, native graph database, open-source & ACID compliant. Stores nodes & relationships between nodes. Sparse, schema-less, storing only what’s needed (no NULLS). Blazingly fast, outperforming SQL RDBMS by orders of magnitude. Infinitely scalable, limited only by hardware. Cypher (Neo4j’s declarative graph query language) is sophisticated, yet easy to learn. Enterprise-ready with SSL APIs, role-based security and high availability. Has the largest, most active developer community of any graph database.
Example:
I have implemented a sample use case, social media analysis (Example: finding common friends, relation between two peoples) (Reference : https://neo4j.com/developer/?ref=home#sample-social)

We need a input dataset to implement the use case. So, let’s create nodes (peoples) and relations as given below,

create (p1:Person {name: “Joe”})-[:knows]->(p2:Person {name: “Bob”}),(p2)-[:knows]->(p3:Person {name: “Sally”}),(p1)-[:knows]->(p3),(p3)-[:knows]->(p4:Person {name: “Anna”}),(p4)-[:knows]->(p5:Person {name: “Jim”}),(p4)-[:knows]->(p6:Person {name: “Mike”}),(p5)-[:knows]->(p6),(p5)-[:knows]->(p7:Person {name: “Billy”})

The graph for the above query is,
Common friend:
Lets say we need to find the person, who is friend of Joe and Sally. We can achieve this by executing the below query,

MATCH (p1:Person)-[:knows]-(friend)-[:knows]-(p2:Person) WHERE p1.name = “Joe” AND p2.name = “Sally” RETURN friend
Result is,
Connecting Paths:
Find all the paths upto 10 degrees, between Joe and Billy. We can get this by executing the below query,

MATCH path = shortestPath((p1:Person)-[:knows*..10]-(p2:Person)) WHERE p1.name = “Joe” AND p2.name = “Billy” RETURN path
Result is,

I have executed all the queries from browser, I need to try using drivers java, python ,… . If you find any new ideas, use cases, suggestions please comment.


1 Comment

An Overview of Graph Algorithms in Neo4j – Rilwan's Blog · May 19, 2018 at 8:09 am

[…] my previous blog, we saw about neo4j with some basic example. In this post, let’s see an overview graph […]

Leave a Reply

%d bloggers like this: