Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-23-2022 04:22 AM
Dear All,
I am new to neo4j. I am using it to store strongly related biological data (nodes are biological entities, edges are connecting verbs of two entities). I have implemented a python Panel User Interface through which Users can search the database based on queries i have implemented. One of the search options is source-target path finding. I am currently using the Dijkstra algorithm from the GDS library. My edges are directed and i do not have weights. My question is the following: Is it possible to get the edge properties from the edges that connect the nodes in the path as return values as well? Because the edge properties yield important information and i would like to visualise the path as well with matplotlib. My current query is this:
Solved! Go to Solution.
11-23-2022 06:20 AM - edited 11-23-2022 06:21 AM
A relationship object has a startNode, an endNide, properties, a type, and an id. All of these are accessible via methods.
The easiest method to extract attributes from a list into a new list is with list comprehension. It allows you to interate through all list elements, apply an optional filter predicate, and apply an optional transformation. The result is a new list. Your current query is using list comprehension to extract the nodeNames. The following will give you a list of the properties from each relationship in ‘path’. Each relationship’s properties is a map, so you will get a list of maps.
[x in relationships(path) | properties(x)]
https://neo4j.com/docs/cypher-manual/current/syntax/lists/#cypher-list-comprehension
11-23-2022 05:24 AM
You can get the relationships from a path ‘p’ from ‘relationships(p)’. This will be a list. For each relationship ‘x’ in the list, you can get its properties from ‘properties(x)’.
11-23-2022 06:07 AM
Thank you, I am getting indeed a list of relationships when adding
11-23-2022 06:20 AM - edited 11-23-2022 06:21 AM
A relationship object has a startNode, an endNide, properties, a type, and an id. All of these are accessible via methods.
The easiest method to extract attributes from a list into a new list is with list comprehension. It allows you to interate through all list elements, apply an optional filter predicate, and apply an optional transformation. The result is a new list. Your current query is using list comprehension to extract the nodeNames. The following will give you a list of the properties from each relationship in ‘path’. Each relationship’s properties is a map, so you will get a list of maps.
[x in relationships(path) | properties(x)]
https://neo4j.com/docs/cypher-manual/current/syntax/lists/#cypher-list-comprehension
All the sessions of the conference are now available online