I am using GSQL to write a algorithm, whose funcion is when given some attribute name(parameter features) of one type vertex, it will return sgc(short for simple graph convolution) feature of the given node.
If I use the flowing code, when the input set features = {“age”}, its output of @@sgc_feature is 2, which is wrong.
CREATE DISTRIBUTED QUERY tg_sgc_v1(VERTEX<some_phone> seed, STRING feature, SET<STRING> features,
STRING v_type, STRING e_type
) FOR GRAPH SomeGraph SYNTAX V1{
MapAccum<STRING, FLOAT> @@sgc_feature;
start = {seed};
FOREACH f_ in features DO
STRING f = f_;
neighbor = SELECT t
FROM start:s -(e_type:e)- v_type:t
ACCUM
@@sgc_feature += (f -> t.getAttr(f, "FLOAT") / (sqrt(s.outdegree(e_type) + 1) * sqrt(t.outdegree(e_type) + 1)))
POST-ACCUM
@@sgc_feature += (f -> s.getAttr(f, "FLOAT") / (s.outdegree(e_type) + 1));
END;
PRINT @@sgc_feature;
}
But I use the flowing code, in which I fix the one f to “age” exactly, it gets @@sgc_feature for “age” attribute is 8.5522, which is right.
CREATE DISTRIBUTED QUERY tg_sgc_v1(VERTEX<some_phone> seed, STRING feature, SET<STRING> features,
STRING v_type, STRING e_type
) FOR GRAPH SomeGraph SYNTAX V1{
MapAccum<STRING, FLOAT> @@sgc_feature;
start = {seed};
FOREACH f_ in features DO
STRING f = f_;
neighbor = SELECT t
FROM start:s -(e_type:e)- v_type:t
ACCUM
@@sgc_feature += (f -> t.getAttr("age", "FLOAT") / (sqrt(s.outdegree(e_type) + 1) * sqrt(t.outdegree(e_type) + 1)))
POST-ACCUM
@@sgc_feature += (f -> s.getAttr(f, "FLOAT") / (s.outdegree(e_type) + 1));
END;
PRINT @@sgc_feature;
}
Can any one figure out why?