aryagraph.algorithms.traversal.bfs_layers#
- aryagraph.algorithms.traversal.bfs_layers(g: Graph, sources: Hashable | Iterable[Hashable]) list[list[Hashable]][source]#
Nodes grouped by hop distance from sources.
sources is a single node or an iterable of nodes (a value that is itself a node of g is always treated as a single node). Layer 0 is the sources; layer
kholds the nodes first reached afterkhops.>>> bfs_layers(Graph([(0, 1), (1, 2), (0, 3)]), 0) [[0], [1, 3], [2]]