Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-26-2020 09:42 PM
I am new to neo4j.
MATCH (s:Bus{bus_no:14}), (l:Bus{bus_no:12})
CALL algo.shortestPath.stream(s, l, "length")
YIELD nodeId,cost
with collect(nodeId) as q
MATCH p= (a)-[r:TRANSMISSION_LINE]-(b)
where id(a)in q and id(b) in q
with distinct(r) as rls
return collect(rls) as e
This query returns a list of relationships.
Every relationship has a property called available_cap
.
l
is a node having a property called load
i want to do
for every rls in e
if rls.availale_cap > l.load
then print( 'ok you can connect')
else print ('you should not connect')
Please help me.
01-27-2020 08:20 AM
You want a case statement. So the if statement turns into something like this:
MATCH (s:Bus{bus_no:14}), (l:Bus{bus_no:12})
CALL algo.shortestPath.stream(s, l, "length")
YIELD nodeId,cost
with collect(nodeId) as q
MATCH p= (a)-[r:TRANSMISSION_LINE]-(b)
where id(a)in q and id(b) in q
with distinct(r) as rls
RETURN
CASE
WHEN rls.availale_cap > l.load THEN 'okay you can connect'
ELSE 'you should not connect' END AS status
I'm not sure exactly how you want to use this or how you want the results formatted, but the above should return one row per rls with a single 'status' column which has one of the two print statements.
For more information on case statements, you can check out the Expressions section of the Cypher manual and go to 2.3.3 CASE expressions.
02-03-2020 11:29 PM
Thanks for the reply.
02-04-2020 07:42 AM
You're welcome. Hope it helped.
02-05-2020 04:52 AM
can please help me for the problem in below link....
https://community.neo4j.com/t/how-to-extract-relationships-from-shortest-path-algorithm/14377
All the sessions of the conference are now available online