#eles.breadthFirstSearch(rootOrOptions?, visitOrDirected?, directed?)
// Breadth-first search over this collection's subgraph
eles.breadthFirstSearch(rootOrOptions?: SearchOptions | Collection<any, any, any> | undefined, visitOrDirected?: boolean | SearchVisitFn | undefined, directed?: boolean | undefined): SearchResultBreadth-first search over this collection's subgraph. Roots are visited in breadth-first order. Multiple callback roots are visited in reverse input order because the initial queue prepends each root; with no roots, the result is empty.
| Name | Description |
|---|---|
rootOrOptions: SearchOptions | Collection<any, any, any> | undefined? | Starting node or an object containing root, visit and directed. |
visitOrDirected: boolean | SearchVisitFn | undefined? | Visit callback, or a direction flag when no callback is needed. |
directed: boolean | undefined? | True to follow outgoing edges only; defaults to false. |
SearchResult{ path, found }: path records roots in input order and discoveries in breadth-first insertion order, with each discovery edge before its node. It can include nodes queued but not visited when the callback stops early. found is the matched node or an empty collection when no callback returned true.
Example
const result = eles.breadthFirstSearch({ root: cy.getElementById('a'), directed: true });console.log(result.path.nodes().map(node => node.id())); // ['a', 'b', 'c']if a root is given as a selector string
Also spelled eles.bfs.