namespace Traverse
undocumented
Functions
traverseBreadthFirstCustom
Returns a stream of connections that can be reached in the given graph starting at the given startNode, and using breadth-first traversal. It can avoid loops if needed in a custom way by supplying the addVisitedNode function.
traverseBreadthFirstCustomgraph starting at the given startNode, and using breadth-first traversal. It can avoid loops if needed in a custom way by supplying the addVisitedNode function.Definition
export declare function traverseBreadthFirstCustom<G extends VariantGraphBase<N, any>, N>(graph: G, startNode: N, addVisitedNode?: (node: N) => boolean): Stream<LinkType<G, N>>;
Type parameters
| Name | Description | 
|---|---|
| G | |
| N | 
Parameters
| Name | Type | Description | 
|---|---|---|
graph | G | the graph to traverse | 
startNode | N | the start node within the graph | 
addVisitedNode | (node: N) => boolean | a function taking the currenty traversed node, and returning true if the node has been traversed before, or false otherwise | 
const g = EdgeGraphHashed.of([1, 2], [2, 3], [1, 3], [3, 4])
const stream = traverseBreadthFirstCustom(g, 1)
console.log(stream.toArray())
// => [[1, 2], [1, 3], [2, 3], [3, 4]]
traverseBreadthFirstHashed
Returns a stream of connections that can be reached in the given graph starting at the given startNode, and using breadth-first traversal. It avoids loops by internally placing the visited nodes in a HashSet builder.
traverseBreadthFirstHashedgraph starting at the given startNode, and using breadth-first traversal. It avoids loops by internally placing the visited nodes in a HashSet builder.Definition
export declare function traverseBreadthFirstHashed<G extends VariantGraphBase<N, V>, N, V>(graph: G, startNode: N): Stream<LinkType<G, N>>;
Type parameters
| Name | Description | 
|---|---|
| G | |
| N | |
| V | 
Parameters
| Name | Type | Description | 
|---|---|---|
graph | G | the graph to traverse | 
startNode | N | the start node within the graph | 
const g = EdgeGraphHashed.of([1, 2], [2, 3], [1, 3], [3, 4])
const stream = traverseBreadthFirstHashed(g, 1)
console.log(stream.toArray())
// => [[1, 2], [1, 3], [2, 3], [3, 4]]
traverseBreadthFirstSorted
Returns a stream of connections that can be reached in the given graph starting at the given startNode, and using breadth-first traversal. It avoids loops by internally placing the visited nodes in a SortedSet builder.
traverseBreadthFirstSortedgraph starting at the given startNode, and using breadth-first traversal. It avoids loops by internally placing the visited nodes in a SortedSet builder.Definition
export declare function traverseBreadthFirstSorted<G extends VariantGraphBase<N, any>, N>(graph: G, startNode: N): Stream<LinkType<G, N>>;
Type parameters
| Name | Description | 
|---|---|
| G | |
| N | 
Parameters
| Name | Type | Description | 
|---|---|---|
graph | G | the graph to traverse | 
startNode | N | the start node within the graph | 
const g = EdgeGraphHashed.of([1, 2], [2, 3], [1, 3], [3, 4])
const stream = traverseBreadthFirstSorted(g, 1)
console.log(stream.toArray())
// => [[1, 2], [1, 3], [2, 3], [3, 4]]
traverseDepthFirstCustom
Returns a stream of connections that can be reached in the given graph starting at the given startNode, and using depth-first traversal. It can avoid loops if needed in a custom way by supplying the addVisitedNode function.
traverseDepthFirstCustomgraph starting at the given startNode, and using depth-first traversal. It can avoid loops if needed in a custom way by supplying the addVisitedNode function.Definition
export declare function traverseDepthFirstCustom<G extends VariantGraphBase<N, any>, N>(graph: G, startNode: N, addVisitedNode?: (node: N) => boolean): Stream<LinkType<G, N>>;
Type parameters
| Name | Description | 
|---|---|
| G | |
| N | 
Parameters
| Name | Type | Description | 
|---|---|---|
graph | G | the graph to traverse | 
startNode | N | the start node within the graph | 
addVisitedNode | (node: N) => boolean | a function taking the currenty traversed node, and returning true if the node has been traversed before, or false otherwise | 
const g = EdgeGraphHashed.of([1, 2], [2, 3], [1, 3], [3, 4])
const stream = traverseDepthFirstCustom(g, 1)
console.log(stream.toArray())
// => [[1, 2], [2, 3], [1, 3], [3, 4]]
traverseDepthFirstHashed
Returns a stream of connections that can be reached in the given graph starting at the given startNode, and using depth-first traversal. It avoids loops by internally placing the visited nodes in a HashSet builder.
traverseDepthFirstHashedgraph starting at the given startNode, and using depth-first traversal. It avoids loops by internally placing the visited nodes in a HashSet builder.Definition
export declare function traverseDepthFirstHashed<G extends VariantGraphBase<N, any>, N>(graph: G, startNode: N): Stream<LinkType<G, N>>;
Type parameters
| Name | Description | 
|---|---|
| G | |
| N | 
Parameters
| Name | Type | Description | 
|---|---|---|
graph | G | the graph to traverse | 
startNode | N | the start node within the graph | 
const g = EdgeGraphHashed.of([1, 2], [2, 3], [1, 3], [3, 4])
const stream = traverseDepthFirstHashed(g, 1)
console.log(stream.toArray())
// => [[1, 2], [2, 3], [1, 3], [3, 4]]
traverseDepthFirstSorted
Returns a stream of connections that can be reached in the given graph starting at the given startNode, and using depth-first traversal. It avoids loops by internally placing the visited nodes in a SortedSet builder.
traverseDepthFirstSortedgraph starting at the given startNode, and using depth-first traversal. It avoids loops by internally placing the visited nodes in a SortedSet builder.Definition
export declare function traverseDepthFirstSorted<G extends VariantGraphBase<N, any>, N>(graph: G, startNode: N): Stream<LinkType<G, N>>;
Type parameters
| Name | Description | 
|---|---|
| G | |
| N | 
Parameters
| Name | Type | Description | 
|---|---|---|
graph | G | the graph to traverse | 
startNode | N | the start node within the graph | 
const g = EdgeGraphHashed.of([1, 2], [2, 3], [1, 3], [3, 4])
const stream = traverseDepthFirstSorted(g, 1)
console.log(stream.toArray())
// => [[1, 2], [2, 3], [1, 3], [3, 4]]