Add vertex id on each hop to the very first vertex

Hi,

I will like to collect the name of the person on each hop and save it as the first vertex’s info.
person - (friendship*1…5) - person

For example, in a 5-hop with the first person name is John and each hop:
John is friends with Mary
Mary is friends with Peter
Peter is friends with April
April is friends with Adam
Adam is friends with Aaron

Results should be John has [“Mary”, “Peter”, “April”, “Adam”, “Aaron”].

Is there a way to do it in GSQL? The accum only collects it for each vertex so John won’t have “Peter”, “April”, “Adam” and “Aaron”. I also want to do this for thousands of vertices so I can’t use a global accum variable.

May be you can use ListAccum to record the paths, a subquery which can return the paths from one vertex,a query with thousands of vertices call the subquery.

1 Like

Can you provide an example?