code | name | dm | date |
---|---|---|---|
1 | a | 1 | 1 |
1 | b | 1 | 2 |
2 | c | 2 | 3 |
3 | e | 2 | 4 |
5 | f | 6 | 5 |
5 | g | 7 | 6 |
6 | h | 8 | 1 |
4 | i | 3 | 1 |
node_code | r_code |
---|---|
1 | 4 |
2 | 4 |
3 | 4 |
5 | 4 |
6 | 4 |
6 | 5 |
有以上两个表格,第一个是节点,第二个为关系,以下是我建立节点及关系的脚本:
create(:node_test{code:1,name:'a',dm:1,date:1})
create(:node_test{code:1,name:'b',dm:1,date:2})
create(:node_test{code:2,name:'c',dm:2,date:3})
create(:node_test{code:3,name:'e',dm:2,date:4})
create(:node_test{code:5,name:'f',dm:6,date:5})
create(:node_test{code:5,name:'g',dm:7,date:6})
create(:node_test{code:6,name:'h',dm:8,date:1})
create(:node_test{code:4,name:'i',dm:3,date:1})
create(:r_test{node_code:1,r_code:4})
create(:r_test{node_code:2,r_code:4})
create(:r_test{node_code:3,r_code:4})
create(:r_test{node_code:5,r_code:4})
create(:r_test{node_code:6,r_code:4})
create(:r_test{node_code:6,r_code:5})
match(f:node_test),(r:r_test),(t:node_test)
where r.node_code=f.code and r.r_code=t.code
merge(f)-[:test]->(t)
但存在的问题是节点表中(name)a、b 应作为为一个节点处理,c、e,f、g分别也应作为一个节点处理,我想以节点表中的code(和dm)分组取每组date最大的一条建立关系,或者在已建立的关系中删除每组date最大一条之外的关系,即最终建立的关系应为b->i,e->i,g->i,h->i,h->g,应怎么处理?