I've analyzed the behavior of the age_relationships()
function - that can be found here - and looking how it works in GDB, it seems that the function is called multiple times for each available path. So, for example, if we want to find all paths between two nodes, the following query must be executed:
SELECT * FROM cypher('graph_name', $$
MATCH (v:Person {lastName: 'Beran'}), (v2:Person {lastName: 'Jones'}), p=((v)-[Knows*..15]-(v2))
RETURN relationships(p)
$$) AS (shortestpath agtype);
The relationships(p)
- which is the same as age_relationships()
- will be called multiple times for every path between these two vertices. Although I though that all paths would be found and retrieved by this function, as something like this pseudo code:
age_relationships(paths):
for every path in paths:
retrieve path
it works the other way around:
for every path in paths:
age_relationships(path):
retrieve path
Why does it work this way?