dgl.traversal.topological_nodes_generator¶
-
dgl.traversal.
topological_nodes_generator
(graph, reverse=False)[source]¶ Node frontiers generator using topological traversal.
Parameters: Returns: Each node frontier is a list or tensor of node ids.
Return type: list of node frontiers
Examples
Given a graph (directed, edges from small node id to large):
2 - 4 / \ 0 - 1 - 3 - 5
>>> g = dgl.DGLGraph([(0, 1), (1, 2), (1, 3), (2, 3), (2, 4), (3, 5)]) >>> list(dgl.topological_nodes_generator(g)) [tensor([0]), tensor([1]), tensor([2]), tensor([3, 4]), tensor([5])]