edgegraph.traversal.breadthfirst.bfs

Contents

edgegraph.traversal.breadthfirst.bfs#

edgegraph.traversal.breadthfirst.bfs(uni, start, attrib, val)#

Perform a breadth-first search.

This function performs a breadth-first search within uni, starting at start, looking for a vertex such that vert[attrib] == val.

This algorithm is detailed in pseudocode in [CLRS09], figure 22.3, and [GoTa60], Algorithm 13.8. Slight modifications have been made to break early when the desired value is found.

Parameters:
  • uni (Universe) – The universe to search in. Set to None for no limitations.

  • start (Vertex) – The vertex to start searching at.

  • attrib (str) – The attribute name to check for each vertex.

  • val (object) – The value to check for in the aforementioned attribute.

Returns:

The vertex which first matched the specified attribute value.

Return type:

Vertex | None