dgl.traversal.bfs_edges_generator¶
-
dgl.traversal.
bfs_edges_generator
(graph, source, reversed=False)[source]¶ Edges frontiers generator using breadth-first search.
Parameters: Returns: Each edge frontier is a list or tensor of edge ids.
Return type: list of edge frontiers
Examples
Given a graph (directed, edges from small node id to large, sorted in lexicographical order of source-destination node id tuple):
2 - 4 / \ 0 - 1 - 3 - 5
>>> g = dgl.DGLGraph([(0, 1), (1, 2), (1, 3), (2, 3), (2, 4), (3, 5)]) >>> list(dgl.bfs_edges_generator(g, 0)) [tensor([0]), tensor([1, 2]), tensor([4, 5])]