def test_1hop_circular_padding(self): """ Sample one hop of neighbors. """ gl.set_padding_mode(gl.CIRCULAR) expand_factor = 6 ids = self._seed_node1_ids nbr_s = self.g.neighbor_sampler(self._edge1_type, expand_factor=expand_factor, strategy="random_without_replacement") nbrs = nbr_s.get(ids) edges = nbrs.layer_edges(1) nodes = nbrs.layer_nodes(1) for iid, nbrs in zip(ids, nodes.ids): full_nbrs = utils.fixed_dst_ids(iid, (100, 200)) utils.check_set_equal(nbrs, full_nbrs)
def test_1hop_using_gremlin(self): """ Using gremlin-like api. """ gl.set_padding_mode(gl.REPLICATE) expand_factor = 6 ids = self._seed_node1_ids nbrs = self.g.V(self._node1_type, feed=ids) \ .outE(self._edge1_type).sample(expand_factor).by("random_without_replacement") \ .inV().emit() edges = nbrs[1] nodes = nbrs[2] for iid, nbrs in zip(ids, nodes.ids): full_nbrs = utils.fixed_dst_ids(iid, (100, 200)) full_nbrs.extend([-1]) utils.check_set_equal(nbrs, full_nbrs)