Neo4j Shortest Path

Return all the first level connections of satish

 
match (e:employee{name:'satish'})-[*1]->(e1) return e,e1

Return all the second level connections of satish

 
match (e:employee{name:'satish'})-[*2]->(e1) return e,e1

Return all the first level and second level connections of satish

 
match (e:employee{name:'satish'})-[*1..2]->(e1) return e,e1

Return all the first level and second level connections of satish that has the follows relationship

 
match (e:employee{name:'satish'})-[:follows*1..2]->(e1:employee) return e,e1

Query for Shortest path between two nodes

 
match(e:employee{name:'satish'}),(e1:employee{name:'tom'}),p=shortestpath((e)-[:follows*1..2]->(e1)) return p

Query for allshortestpaths between nodes

 
match(e:employee{name:'satish'}),(e1:employee{name:'tom'}),p=allshortestpaths((e)-[:follows*1..2]->(e1)) return p

Display all employees who follow satish and is followed by satish

 
match(e:employee)-[f:follows]->(e1:employee{name:'satish'})-[f1:follows]->(e2:employee) return e,f,e1,f1,e2