查询节点的邻居节点,并且每种类型的邻居返回m条

  • cypher
    • MATCH path =(n:实体标签)--(m) WHERE n.name='aa' with m.type as mtype,collect(path)[..m] as paths return paths;
    • MATCH(n:实体标签{name:'aa'})-[r]-(m) with m.type as tp,collect(r)[..m] as rels unwind rels as r return startNode(r),endNode(r),type(r)
  • apoc 动态cypher
    • MATCH(n:实体标签{name:'aa'}) CALL apoc.path.subgraphAll(n,{relationshipFilter:NULL,labelFilter:NULL,maxLevel:1}) YIELD relationships UNWIND relationships AS r with endNode(r).type AS lab, collect(r)[..m] as rels UNWIND rels AS rel RETURN startNode(rel).name AS fromNode, endNode(rel).name AS toNode, type(rel) as relType
原文地址:https://www.cnblogs.com/liangxinxinbo/p/13476637.html