def _receptive_fn(self, nodes): if nodes.type == 'u': neighs_num = self.u_neighs_num return self.graph.V(nodes.type, nodes).alias('v').outV("u-i")\ .sample(neighs_num[0]).by("random").alias('v1')\ .emit(lambda x: gl.EgoGraph(x['v'], [gl.Layer(nodes=x['v1'])])) else: neighs_num = self.i_neighs_num return self.graph.V(nodes.type, nodes).alias('v').inV("u-i")\ .sample(neighs_num[0]).by("random").alias('v1')\ .emit(lambda x: gl.EgoGraph(x['v'], [gl.Layer(nodes=x['v1'])]))
def _receptive_fn(self, nodes): alias = ['v' + str(i + 1) for i in range(self.hops_num)] # sample based if self.neighs_num is not None: assert len(self.neighs_num) == self.hops_num sample_func = lambda v, params: v.outV(self.edge_type).sample(params).by('topk') return self.graph.V(nodes.type, feed=nodes).alias('v')\ .repeat(sample_func, self.hops_num, params_list=self.neighs_num, alias_list=alias)\ .emit(lambda x: gl.EgoGraph(x['v'], [gl.Layer(nodes=x[name]) for name in alias])) # full batch based sample_func = lambda v: v.outV(self.edge_type).sample().by('full') return self.graph.V(nodes.type, feed=nodes).alias('v')\ .repeat(sample_func, self.hops_num, alias_list=alias)\ .emit(lambda x: gl.EgoGraph(x['v'], [gl.Layer(nodes=x[name]) for name in alias]))