A breadth-first search algorithm.

Can have a custom propagation function to determine which edges to follow, effectively pruning the search tree.

Can be set to be undirected, in which case it will also use incoming edges to traverse the graph, disregarding edge direction.

Implements

Constructors

Properties

directed: boolean

Whether the search is to be considered directed or undirected.

propagate: ((edge: BaseEdge.Class<BaseEdge.Data, BaseEdge.ScratchData>) => boolean)

A function that determines whether to propagate a given edge.

Methods

  • Starts a search from a given root node. This method is a generator, so it is usually implemented like:

    export default class MySearch implements Node.Search {
    *search(root: BaseNode.Class): Generator<SearchVisit> {
    // Your implementation here
    }
    }

    And uses the yield keyword to return values.

    Parameters

    Returns Generator<SearchVisit, any, any>

    A generator that yields each visit, so that it can be lazily iterated over.