0

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?

Matheus Farias
  • 716
  • 1
  • 10

2 Answers2

0

This occurs because the Cypher MATCH clause finds and retrieves every path between the two nodes in a query like (v)-[*]-(v2). Therefore, the function relationships takes this path and retrieves every other entry from the path (to obtain just the edges).

To gain a better understanding of how this path is constructed, you can debug the transform_cypher_match function and other related functions in the cypher_clause.c file.

Wendel
  • 763
  • 1
  • 12
0

The reason is that the function age_relationships(paths) works on every path individually when the Cypher Query returns the results to this function.

By this individually working approach on each path, the process becomes performance-optimized for complex queries.

adil shahid
  • 125
  • 4