Help on how to show most common relations shared by two nodes

I am facing difficulty to retrieve the highest no of relationships shared by two nodes from the data. i am able to count highest no of relations but hard to show in a graph.

     MATCH path = (e1:Employee) -->(n)<--(e2:Employee)
     WITH count(n) as count,e1 as employee, e2 as employees
     WHERE count > 2
     RETURN count,employee,employees  

the result i got is

How can i show the relations shared between them.

MATCH (e1:Employee)-[r]-(e2:Employee)
WHERE id(e2) <> id(e1)
RETURN distinct e1.empid as emp, type(r) as rel, count(r) as cnt ORDER BY cnt desc

Say if rel = "R1" has maximum count, then
MATCH (e1:Employee)-[:R1]-(e2:Employee)
RETURN e1, e2

i tried above query
no changes no records

Run this:
MATCH (e1:Employee)-[]-(e2)

Check to see if e1 is connected to any other node.,

Thanks for the info. This shows Employee node is having relationships with nodes that represent the employee location. Looks like no two employee nodes are connected directly.

Try this:
MATCH (e1:Employee)-[]-(e2:Employee)
RETURN e1, e2

Anything wrong with my data modelling?

What kind of relationship are you expecting between two employee nodes?

Definitely, no such relationship is existing.If you can share your Cypher ingestion query so that I can help you.

LOAD CSV WITH HEADERS FROM 'file:///y.csv' AS line
MERGE (a:Employee {empid:line.EmpID})
ON CREATE SET a.firstname = line.FirstName, a.lastname = line.LastName
MERGE (g:Gender{gender:line.Gender})
Merge (a)-[:GENDER]-(g)
MERGE (ag:Age {age:toInteger(line.AgeinYrs)})
MERGE (a)-[:AGE]-(ag)
MERGE (y:Year {year:toInteger(line.YearofJoining)})
Merge (a)-[:YEAR_OF_JOINING]-(y)
MERGE (m:Month {month:line.MonthNamofJoining})
merge (a)-[:JOINING_MONTH]-(m)
Merge (c:City {city:line.City})
Merge (a)-[:CITY]-(c)
Merge (p:Pincode{pincode:line.PinCode})
Merge (a)-[:PINCODE]-(p)
Merge (C:County {county:line.County})
Merge (a)-[:COUNTY]-(C)
Merge (r:Region {region:line.Region})
Merge (a)-[:REGION]-(r)
Merge (s:State{state:line.State})
Merge (a)-[:STATE]-(s)
return a,y,m,ag,p,C,r,s,g limit 25

This the model i am trying to build for a employee data. i want to know the highest common relations shared by any two employess.

Try this:

match (e:Employee)-[]-(y:Year)
with distinct y.year as year, collect(distinct e.empid) as eid
return year, eid, size(eid)

This gives you the number of employees joined in a given year. eid is an array of empires and size(eid) is like count of employees.
1 Like

yes its giving