# dgl.traversal¶

Module for graph traversal methods.

Graph traversal algorithms implemented as python generators, which returns the visited set of nodes or edges at each iteration. The naming convention is <algorithm>_[nodes|edges]_generator. An example usage is as follows.

g = ...  # some DGLGraph
for nodes in dgl.bfs_nodes_generator(g, 0):
do_something(nodes)

 bfs_nodes_generator(graph, source[, reverse]) Node frontiers generator using breadth-first search. bfs_edges_generator(graph, source[, reverse]) Edges frontiers generator using breadth-first search. topological_nodes_generator(graph[, reverse]) Node frontiers generator using topological traversal. dfs_edges_generator(graph, source[, reverse]) Edge frontiers generator using depth-first-search (DFS). dfs_labeled_edges_generator(graph, source[, …]) Produce edges in a depth-first-search (DFS) labeled by type.