the question I have is here : cypher-how-get-relation-between-every-two-node-and-the-distance-from-start-node, more detail here: 2 million companies, each of them must and only belong to a leading company,called group, so every node has properties: groupId and companyId; what's more, companies in different group may have relationship. QUESTION: given a groupId and the leading company id, return all relations in this group and every node in the group's shortest distance to leading company.
since the sql that anwser have big performance issue, especially the shortPath one, so my question is can we narrow down the search scope when use shortPath, only search nodes with same property?
or are there other way to solve the original question?
sorry since I am in China mainland, cannot reach the console.neo4j.com(even with VPN), so I put my sample here:
create (a :COMPANY {companyId:"a",groupId:"ag"}),
(b:COMPANY {companyId:"b",groupId:"ag"}),
(c:COMPANY {companyId:"c",groupId:"ag"}),
(d:COMPANY {companyId:"d",groupId:"ag"}),
(e:COMPANY {companyId:"e",groupId:"eg"})
create (a)-[:INVESTMENT]->(b),
(b)-[:INVESTMENT]->(c),
(c)-[:INVESTMENT]->(d),
(a)-[:INVESTMENT]->(c),
(d)-[:INVESTMENT]->(b),
(c)-[:INVESTMENT]->(e)
return *
here the node a,b,c,d
are same group and a
is leading company,e
are another group but has relationship with c
. so I want get the node-node relation in ag
group, for example: a-b,a-c,b-c,c-d,d-b
and the shortest distance from a
to group member, for example,return dist.a=0,dist.b=1,dist.c=1,dist.d=2