CREATE INDEX ON :Leaf(id); MATCH (u:Leaf) SET u.value = 1; MATCH (u) WHERE NOT u:Leaf SET u.value = 0; MATCH (u) WITH u ORDER BY u.topological_index DESC MATCH (u)-->(v) SET u.value = u.value + v.value; MATCH (u:Leaf {id: "85000"}) SET u.value = 10; MATCH (u:Leaf {id: "85000"})<-[* bfs]-(v) WHERE NOT v:Leaf SET v.value = 0; MATCH (u:Leaf {id: "85000"})<-[* bfs]-(v) WITH v ORDER BY v.topological_index DESC MATCH (v)-->(w) SET v.value = v.value + w.value;