Convert the Graph into numpy format. In numpy format, the graph edges and node features are in numpy.ndarray format. But you can't use send and recv in numpy graph. Args: inplace: (Default True) Whether to convert the graph into numpy inplace.
(self, inplace=True)
| 410 | return value |
| 411 | |
| 412 | def numpy(self, inplace=True): |
| 413 | """Convert the Graph into numpy format. |
| 414 | |
| 415 | In numpy format, the graph edges and node features are in numpy.ndarray format. |
| 416 | But you can't use send and recv in numpy graph. |
| 417 | |
| 418 | Args: |
| 419 | |
| 420 | inplace: (Default True) Whether to convert the graph into numpy inplace. |
| 421 | |
| 422 | """ |
| 423 | if not self._is_tensor: |
| 424 | return self |
| 425 | |
| 426 | if inplace: |
| 427 | for key in self.__dict__: |
| 428 | self.__dict__[key] = self._apply_to_numpy( |
| 429 | key, self.__dict__[key], inplace) |
| 430 | return self |
| 431 | else: |
| 432 | new_dict = {} |
| 433 | for key in self.__dict__: |
| 434 | new_dict[key] = self._apply_to_numpy(key, self.__dict__[key], |
| 435 | inplace) |
| 436 | |
| 437 | graph = self.__class__( |
| 438 | num_nodes=new_dict["_num_nodes"], |
| 439 | edges=new_dict["_edges"], |
| 440 | node_feat=new_dict["_node_feat"], |
| 441 | edge_feat=new_dict["_edge_feat"], |
| 442 | adj_src_index=new_dict["_adj_src_index"], |
| 443 | adj_dst_index=new_dict["_adj_dst_index"], |
| 444 | **new_dict) |
| 445 | return graph |
| 446 | |
| 447 | def dump(self, path): |
| 448 | """Dump the graph into a directory. |
no test coverage detected