Get sampled `SubGraph`. Return: An `SubGraph` object. Raise: `graphlearn.OutOfRangeError`
(self)
| 54 | self._node_type = topology.get_src_type(self._nbr_type) |
| 55 | |
| 56 | def get(self): |
| 57 | """ Get sampled `SubGraph`. |
| 58 | |
| 59 | Return: |
| 60 | An `SubGraph` object. |
| 61 | Raise: |
| 62 | `graphlearn.OutOfRangeError` |
| 63 | """ |
| 64 | state = self._graph.node_state.get(self._seed_type) |
| 65 | req = pywrap.new_subgraph_request( |
| 66 | self._seed_type, |
| 67 | self._nbr_type, |
| 68 | strategy2op(self._strategy, "SubGraphSampler"), |
| 69 | self._batch_size, |
| 70 | state) |
| 71 | res = pywrap.new_subgraph_response() |
| 72 | |
| 73 | status = self._client.sample_subgraph(req, res) |
| 74 | if status.ok(): |
| 75 | node_ids = pywrap.get_node_set(res) |
| 76 | row_idx = pywrap.get_row_idx(res) |
| 77 | col_idx = pywrap.get_col_idx(res) |
| 78 | edge_ids = pywrap.get_edge_set(res) |
| 79 | else: |
| 80 | if status.code() == errors.OUT_OF_RANGE: |
| 81 | if self._client.connect_to_next_server(): |
| 82 | return self.get() |
| 83 | self._graph.node_state.inc(self._seed_type) |
| 84 | |
| 85 | pywrap.del_op_response(res) |
| 86 | pywrap.del_op_request(req) |
| 87 | errors.raise_exception_on_not_ok_status(status) |
| 88 | |
| 89 | nodes = self._graph.get_nodes(self._node_type, node_ids) |
| 90 | return SubGraph(np.stack([row_idx, col_idx], axis=0), nodes, Edges(edge_ids=edge_ids)) |
| 91 | |
| 92 | |
| 93 | class RandomNodeSubGraphSampler(SubGraphSampler): |
nothing calls this directly
no test coverage detected