节点分类,方法和语句讨论
发布于 5 年前 作者 bingo 1967 次浏览 来自 问答

企业微信截图_15694183342075.png 目标:左一的图按照右一显示

1.同一种关系,链接的节点数大于等于2时候,构建虚拟节点,如右侧红色的节点,并标识红色节点由几个节点组成(张三的关系为”手机“的节点有 手机1,手机2,手机3,手机4,手机5,手机6)

2.同一种关系,链接的节点数小于2的时候,显示真实节点,并显示真是节点连接有多少其他节点(人1关联的节点有人2,人3,人4,爬出本身“张三”的节点)

当一个节点很多种关系的时候。想把节点进行“分类归纳”,我写的语句如下。请教各位老师。有没有更好的方法或者语句,与君讨论 match(f:人{身份证:‘513902198603078888’})-[rr]-(t)
with f,type(rr) as r1 ,count(distinct t) as cnt where cnt <2 match(f)-[vr]-(vt) where type(vr)=r1 with f,vr,vt,filter(x in [(vt)–§|p] where x<>f ) as pctlist with f,vr,vt,case when pctlist is null then 0 else size(pctlist) end as pct return f,vr,vt,pct union all match(f:人{身份证:‘513902198603078888’})-[rr]-(t)
with f,type(rr) as r ,count(distinct t) as cnt where cnt >=2 with f,r,cnt,apoc.create.vNode([‘virtual’],{count:cnt,fromid:id(f),type:‘virtual’ }) as vt with f,vt,cnt, apoc.create.vRelationship(f,r,{type:‘virtual’},vt) as vr return f,vr,vt,0 as pct;

1 回复

自己up一下

回到顶部