GraphGists

The example graph consists of characters in Mahabharata - the Indian Epic. Key nodes - Relations, Wars and their key actions

We’ll go with key characters. There is great debate on Mahabharata genealogy, so we will stick to Wikipedia version for now https://en.wikipedia.org/wiki/Mahabharata

This gives us the following graph to play with:

Let’s check how many nodes we have now: Cypher 01

Match (n) RETURN "Hello Graph with " + count(*) + " Nodes! in first Gist by Shivprakash Swami " AS welcome;

List all nodes and their relationships: Cypher 02

MATCH (n)-[r]->(m)  RETURN n AS from, r AS `->`, m AS to;

List most well-connected nodes in desc order: Cypher 03

Match p=(n)--()
return n, count(distinct p) as connectedness
order by connectedness desc limit 5;

Let’s get shortest path between Bhima and Dusshala: Cypher 04

MATCH (Bhima:Person { name:"Bhima" }),(Dusshala:Person { name:"Dusshala" }),
  p = allShortestPaths((Bhima)-[*1..15]-(Dusshala))
RETURN p;

Days with most killings in war in descending order: Cypher 05

MATCH (n)-[r:`KILLED`]-(m) return r.Day,count(m) as deaths order by deaths desc;

most prolific warrior: Cypher 06

MATCH (n)-[r:`KILLED`]-(m) return n.name,count(m) as victims order by victims desc