コード例 #1
0
  def test_1hop_using_gremlin(self):
    """ Topk neighbor sample with gremlin-like api.
    """
    gl.set_padding_mode(gl.REPLICATE)
    ids = self._seed_node2_ids
    nbrs = self.g.V(self._node2_type, feed=ids) \
      .outE(self._edge2_type).sample(2).by("topk") \
      .inV().emit()

    edges = nbrs[1]

    utils.check_topk_edge_ids(edges, ids,
                              (0, 100), expand_factor=2,
                              default_dst_id=self._default_dst_id)
    utils.check_half_exist_edge_weights(
        edges, default_dst_id=self._default_dst_id)
コード例 #2
0
    def test_1hop_replicate_padding(self):
        """ Sample topk neighbors.
    """
        gl.set_padding_mode(gl.REPLICATE)
        ids = self._seed_node2_ids
        nbr_s = self.g.neighbor_sampler(self._edge2_type, 6, strategy="topk")
        nbrs = nbr_s.get(ids)
        edges = nbrs.layer_edges(1)
        nodes = nbrs.layer_nodes(1)

        utils.check_topk_edge_ids(edges,
                                  ids, (0, 100),
                                  expand_factor=6,
                                  default_dst_id=self._default_dst_id)
        utils.check_half_exist_edge_weights(
            edges, default_dst_id=self._default_dst_id)