aryagraph.algorithms.traversal.bfs_edges#

aryagraph.algorithms.traversal.bfs_edges(g: Graph, source: Hashable, *, reverse: bool = False, depth_limit: int | None = None) → list[tuple[Hashable, Hashable]][source]#

Edges of the breadth-first search tree rooted at source, in discovery order.

Parameters:
  • reverse – On a directed graph, follow arcs backwards (predecessors). Tree edges are still reported (parent, child), i.e. against the arc direction.

  • depth_limit – Only explore nodes at most this many hops from source.

Examples

>>> bfs_edges(Graph([(0, 1), (0, 2), (1, 3)]), 0)
[(0, 1), (0, 2), (1, 3)]