Shortestpath for each node

时间:2017-06-19 14:02:05

标签: neo4j cypher

I want to find a shortestpath to a nearby node with certain props. This one works:

match (st:station {kind:'Small'})
with st limit 1 
match p =  ShortestPath((st) - [:installation|cable*1..25] - (st1:station )  )
where st1.kind IN ['Biggest', 'Bigger', 'Big'] AND ALL(idx in filter ( x IN relationships(p) WHERE type(x) = 'Connection') WHERE idx.switch= 'Closed')
with st, st1 
match p2 = ShortestPath((st) - [:installation|cable*1..25] - (st1) )
where ALL(idx in filter ( x IN relationships(p2) WHERE type(x) = 'Connection') WHERE idx.switch= 'Closed')
with st, p2 order by length(p2) limit 1 
with st, head(tail(filter ( x IN relationships(p2) WHERE type(x) = 'Connection'))) as vb
set vb.feeding='True', st.done='True' )

It finds the Dijkstra SSSP shortest paths forrest from which I subsequently take the shortest one (determined by doing multiple shortestpaths with FIXED endpoints).

When I leave out the first 'limit 1' the query never returns and no updates are done. When using limit 2 or 3, the FIRST node found is updated, none other.

What am I missing here? Anyone?

0 个答案:

没有答案