Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-09-2021 07:16 AM
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
02-09-2021 09:47 AM
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
02-09-2021 10:07 PM
i tried above query
no changes no records
02-09-2021 10:35 PM
Run this:
MATCH (e1:Employee)-[]-(e2)
RETURN e1, e2 LIMIT 6
Check to see if e1 is connected to any other node.,
02-09-2021 10:43 PM
02-09-2021 11:42 PM
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
02-10-2021 04:28 AM
Anything wrong with my data modelling?
02-10-2021 10:40 AM
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.
02-11-2021 01:47 AM
:auto USING PERIODIC COMMIT 5
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.
02-11-2021 01:19 PM
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.
02-12-2021 03:47 AM
yes its giving
All the sessions of the conference are now available online