How can I access an accumulator in another accumlator

start={A.*};

SetAccum<VERTEX> @Xs;

MaxAccum<VERTEX> @Y

// A->X is an n…n relationship

start = select a from start:a-()->X:x

         accum a.@Xs += x;

// A->Y is an 1…n relationship

Ys = select y from start:a-()->Y:y

         accum y.@Y += a;

// now each c contains an A who has a set of X;

// Y->X is an n…1 relationship

result = select x from Ys:y-()->X:x

        // now I want to do...

        // error query at present

if y.@Y.@Xs.contains(x) then

         // do something to tag the accepted x

        end;

When mouse cursor is over the red text, reports:

no viable alternative at input ‘y.@y.@Xs

no viable alternative at input ‘.@Xs

How to solve this? Thanks!

We don’t access accumulators in another accumulator. Reading your code, I think you’re trying to match a pattern of triangle, and do something on the X vertices. A memory efficient solution can be like this:

start={A.*};

MaxAccum<Vertex> @yA;
SetAccum<Vertex
> @xA;

// A->Y is an 1…n relationship, so each Y is connected to only 1 A.

Ys = select y from start:a-()->Y:y
accum y.@yA = a; //y.@yA stores its connected A

// Y->X is an n…1 relationship, so each Y is connected to only one X

result = select x from Ys:y-()->X:x
accum x.@xA += y.@yA; //stores all the A which can reach to X.

// A->X is a n…n relationship

start = select a from start:a-()->X:x
where x.@xA contains(a)
//do something about X.