dgl.block_to_graph¶
-
dgl.
block_to_graph
(block)[source]¶ Convert a message flow graph (MFG) as a
DGLBlock
object to aDGLGraph
.DGL will rename all the source node types by suffixing with
_src
, and all the destination node types by suffixing with_dst
.Features on the returned graph will be preserved.
- Parameters
block (DGLBlock) – The MFG.
- Returns
The graph.
- Return type
Examples
>>> block = dgl.create_block({ ... ('A', 'AB', 'B'): ([1, 2, 3], [2, 1, 0]), ... ('B', 'BA', 'A'): ([2, 1], [2, 3])}) >>> g = dgl.block_to_graph(block) >>> g Graph(num_nodes={'A_src': 4, 'B_src': 3, 'A_dst': 4, 'B_dst': 3}, num_edges={('A_src', 'AB', 'B_dst'): 3, ('B_src', 'BA', 'A_dst'): 2}, metagraph=[('A_src', 'B_dst', 'AB'), ('B_src', 'A_dst', 'BA')])