Getting the next node given a subset of nodes

New to TigerGraph here…

Assume that I have these nodes and relationships already persisted in DB:
3 > 5 > 9 > 8 > 0

When 3 > 5 > 9 is given as a parameter (as a vertex list), I’d like to write a GSQL function that return node 8. So basically a function that returns the subsequent node given a matching-subset of previous nodes.

I was looking around in the tutorials for a while (on SELECT statements, ACCUM, etc… ), but couldn’t find a solid solution.

Hmmm. Thinking.

Why do we need more than 9 in this list? Do the 3 and the 5 somehow condition the next step(s)?

If the edges are undirected, then possibly we need 5 and 9 (to avoid returning the 5). Same question for the 3 though.

Hi,

You can assume that edge are directed.

Idea here is to get the next node given a lineage of nodes that happened to the subset of the parent node list that’s persisted in DB. I understand that there are edge-cases, like what happens if there’s always no match, etc… For now, let’s not worry too much about those edge-cases - I’m pretty sure I can resolve those on my own later on.

May have found an answer here - Query argument type jsonarray

OK. Good luck with that. If you do get stuck though, let me know on the other questions. Why do we need more than 9 in that list?

If we don’t, then it is a single hop link via the edge from “9”.