我先取n邻居:(在此示例中,n = 6)
我有一个加权图,所以我也按重量排序结果:
START start_node=node(1859988)
MATCH start_node-[rel]-(neighbor)
RETURN DISTINCT neighbor,
rel.weight AS weight ORDER BY proximity DESC LIMIT 6;
我想获取一个完整的子图,包括第二个邻居(前六个孩子的第一个邻居)。
我试过 smtg 喜欢:
START start_node=node(1859988)
MATCH start_node-[rel]-(neighbor)
FOREACH (neighbor | MATCH neighbor-[rel2]-(neighbor2) )
RETURN DISTINCT neighbor1, neighbor2, rel.proximity AS proximity ORDER BY proximity DESC LIMIT 6, rel2.proximity AS proximity ORDER BY proximity DESC LIMIT 6;
语法仍然错误,但我也不确定输出:我想要一个元组表,父、子和权重:[node_A - node_B - weight]
我想看看它是执行一个查询还是六个查询更好。有人可以帮助澄清如何迭代查询(FOREACH)并格式化输出吗?
谢谢你!