Neo4j:遍历关系集合并将 属性 设置为索引

Neo4j: Iterate through collection of relationships and set property to index

在经典的 for(i etc.){ ... } 风格中,我想遍历有序集合 - 伪代码:

for n,i in nodes
  set node.weight = i + 1
end

可行吗?

是的,但不是最漂亮的:

MATCH ...
WITH COLLECT(something) AS nodes
FOREACH(i IN RANGE(0, LENGTH(nodes)) |
    FOREACH(node IN [nodes[i]] |
        SET node.weight = i + 1
))