Create a message flow graph (MFG) as a :class:`DGLBlock` object. Parameters ---------- data_dict : graph data The dictionary data for constructing a MFG. The keys are in the form of string triplets (src_type, edge_type, dst_type), specifying the source node type,
(
data_dict,
num_src_nodes=None,
num_dst_nodes=None,
idtype=None,
device=None,
node_count_check=True,
)
| 387 | |
| 388 | |
| 389 | def create_block( |
| 390 | data_dict, |
| 391 | num_src_nodes=None, |
| 392 | num_dst_nodes=None, |
| 393 | idtype=None, |
| 394 | device=None, |
| 395 | node_count_check=True, |
| 396 | ): |
| 397 | """Create a message flow graph (MFG) as a :class:`DGLBlock` object. |
| 398 | |
| 399 | Parameters |
| 400 | ---------- |
| 401 | data_dict : graph data |
| 402 | The dictionary data for constructing a MFG. The keys are in the form of |
| 403 | string triplets (src_type, edge_type, dst_type), specifying the source node type, |
| 404 | edge type, and destination node type. The values are graph data in the form of |
| 405 | :math:`(U, V)`, where :math:`(U[i], V[i])` forms the edge with ID :math:`i`. |
| 406 | The allowed graph data formats are: |
| 407 | |
| 408 | - ``(Tensor, Tensor)``: Each tensor must be a 1D tensor containing node IDs. DGL calls |
| 409 | this format "tuple of node-tensors". The tensors should have the same data type, |
| 410 | which must be either int32 or int64. They should also have the same device context |
| 411 | (see below the descriptions of :attr:`idtype` and :attr:`device`). |
| 412 | - ``('coo', (Tensor, Tensor))``: Same as ``(Tensor, Tensor)``. |
| 413 | - ``('csr', (Tensor, Tensor, Tensor))``: The three tensors form the CSR representation |
| 414 | of the graph's adjacency matrix. The first one is the row index pointer. The |
| 415 | second one is the column indices. The third one is the edge IDs, which can be empty |
| 416 | to represent consecutive integer IDs starting from 0. |
| 417 | - ``('csc', (Tensor, Tensor, Tensor))``: The three tensors form the CSC representation |
| 418 | of the graph's adjacency matrix. The first one is the column index pointer. The |
| 419 | second one is the row indices. The third one is the edge IDs, which can be empty |
| 420 | to represent consecutive integer IDs starting from 0. |
| 421 | |
| 422 | The tensors can be replaced with any iterable of integers (e.g. list, tuple, |
| 423 | numpy.ndarray). |
| 424 | |
| 425 | If you would like to create a MFG with a single source node type, a single destination |
| 426 | node type, and a single edge type, then you can pass in the graph data directly |
| 427 | without wrapping it as a dictionary. |
| 428 | num_src_nodes : dict[str, int] or int, optional |
| 429 | The number of nodes for each source node type, which is a dictionary mapping a node type |
| 430 | :math:`T` to the number of :math:`T`-typed source nodes. |
| 431 | |
| 432 | If not given for a node type :math:`T`, DGL finds the largest ID appearing in *every* |
| 433 | graph data whose source node type is :math:`T`, and sets the number of nodes to |
| 434 | be that ID plus one. If given and the value is no greater than the largest ID for some |
| 435 | source node type, DGL will raise an error. By default, DGL infers the number of nodes for |
| 436 | all source node types. |
| 437 | |
| 438 | If you would like to create a MFG with a single source node type, a single destination |
| 439 | node type, and a single edge type, then you can pass in an integer to directly |
| 440 | represent the number of source nodes. |
| 441 | num_dst_nodes : dict[str, int] or int, optional |
| 442 | The number of nodes for each destination node type, which is a dictionary mapping a node |
| 443 | type :math:`T` to the number of :math:`T`-typed destination nodes. |
| 444 | |
| 445 | If not given for a node type :math:`T`, DGL finds the largest ID appearing in *every* |
| 446 | graph data whose destination node type is :math:`T`, and sets the number of nodes to |
no test coverage detected