SPeCS Packages Documentation
    Preparing search index...

    A depth-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

    Index

    Constructors

    Properties

    directed: boolean

    Whether the search is to be considered directed or undirected.

    propagate: (edge: BaseEdge.Class) => 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>

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

    • Sets the propagation function for the edges. The propagation function should return a boolean that determines whether to propagate the edge.

      Parameters

      • propagate: (edge: BaseEdge.Class) => boolean

        The propagation function to set.

      Returns this

      This search instance, for chaining.

    • Sets the search to be undirected. An undirected search may travel through edges in both directions, so it can also use incoming edges.

      Returns this