dangraph / Exports / directed_graph/danDirectedGraphDepthFirstIterator / DanDirectedGraphDepthFirstIterator
directed_graph/danDirectedGraphDepthFirstIterator.DanDirectedGraphDepthFirstIterator
The class DanDirectedGraphDepthFirstIterator implements GraphIterator interface
| Name |
|---|
I |
D |
GraphIterator<DanNode<I,D>>
• new DanDirectedGraphDepthFirstIterator<I, D>(collection, startingNodeId): DanDirectedGraphDepthFirstIterator<I, D>
The public class constructor
| Name |
|---|
I |
D |
| Name | Type | Description |
|---|---|---|
collection |
DanDirectedGraph<I, D> |
the directed graph |
startingNodeId |
I |
the starting node identifier |
DanDirectedGraphDepthFirstIterator<I, D>
Throws
exception if startingNodeId was not found in graph
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:33
• Private _currentNodeId: null | I
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:21
• Private _graph: DanDirectedGraph<I, D>
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:15
• Private _nextNodeId: null | I
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:23
• Private _stack: DanStack<IterableIterator<[I, DanArc<I, D>]>>
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:25
• Private _startingNodeId: I
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:19
• Private _visitedNodes: Set<I>
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:17
▸ _advance(): void
Advance to the next node in a depth first fashion
void
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:111
▸ _getNodeAndDirectedArcsFromNodeId(nodeId): DanNodeAndDirectedArcs<I, D>
Retrieve node and directed arcs structure from node identifier
| Name | Type | Description |
|---|---|---|
nodeId |
I |
the node identifier |
DanNodeAndDirectedArcs<I, D>
the node and directed arcs structure DanNodeAndDirectedArcs
Throws
exception if nodeId was not found in graph
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:46
▸ _initFields(startingNodeId): void
Init the class fields with the starting node identifier passed in input
| Name | Type | Description |
|---|---|---|
startingNodeId |
I |
the starting node identifier |
void
Throws
exception if startingNodeId was not found in graph
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:59
▸ current(): undefined | DanNode<I, D>
Get the current node, or return undefined if iterator was not yet started
undefined | DanNode<I, D>
Throws
exception if this._currentNodeId was not found in graph
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:78
▸ hasNext(): boolean
Check if the iterator can step to a next node
boolean
true if the iterator can step to a next node, false if there are no more nodes left to visit in the iterator
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:160
▸ next(): undefined | DanNode<I, D>
Get the next node, or return undefined if the iterator's end was reached
undefined | DanNode<I, D>
Throws
exception if this._nextNodeId was not found in graph
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:91
▸ rewind(): void
Restart the iterator
void
src/directed_graph/danDirectedGraphDepthFirstIterator.ts:167