答案 0 :(得分:1)
我假设您在每个y2 <- c(0,0,NA,0,0,0,0); y <- c(0,0,0,NA,NA,0); x <- c(0,0,0,0)
li <-list(y2 = y2,y = y,x = x)
## This is your example, where x is subset of both y and y2
uniquePath(li)
# [[1]]
# [1] 0 0 NA 0 0 0 0
#
# [[2]]
# [1] 0 0 0 NA NA 0
x <- c(0,0,0,0); y <- c(0,NA,0,0,0); y2 <- c(NA,NA,0,0,0,0)
l <- list(x,y,y2)
## Here x is a subset of y and y is a subset of y2
uniquePath(l)
# [[1]]
# [1] NA NA 0 0 0 0
节点中都有order
属性。我正在使用此示例数据:
:B
然后您可以使用此Cypher查询:
CREATE (a1:A)-[:R]->(:B {order : 1}), (a1)-[:R]->(:B {order : 2}), (a1)-[:R]->(:B {order : 3})
CREATE (a2:A)-[:R]->(:B {order : 1}), (a2)-[:R]->(:B {order : 2}), (a2)-[:R]->(:B {order : 3})
输出将是:
答案 1 :(得分:1)
另外一个选项:使用APOC Procedures。过程apoc.nodes.link()
接收节点集合,并使用指定的关系类型将它们转换为链接列表。用法示例:
MATCH (A:A)-[:R]->(B:B)
WITH A, B
ORDER BY B.order ASC
WITH A, collect(B) as bNodes
CALL apoc.nodes.link(bNodes, 'NEXT')
答案 2 :(得分:0)
dataframe