dangraph / Exports / directed_graph/danDirectedGraphBreadthFirstIterator / DanDirectedGraphBreadthFirstIterator
directed_graph/danDirectedGraphBreadthFirstIterator.DanDirectedGraphBreadthFirstIterator
The class DanDirectedGraphBreadthFirstIterator implements GraphIterator interface
| Name |
|---|
I |
D |
GraphIterator<DanNode<I,D>>
- _currLevelQueue
- _currLevelQueuePosition
- _currentNodeId
- _graph
- _nextLevelQueue
- _nextLevelSet
- _nextNodeId
- _startingNodeId
- _visitedNodes
- _addNextNodeOutgoingsToNextLevelQueueIfNotAlreadyVisitedOrQueued
- _advance
- _getNodeAndDirectedArcsFromNodeId
- _initFields
- current
- hasNext
- next
- rewind
• new DanDirectedGraphBreadthFirstIterator<I, D>(collection, startingNodeId): DanDirectedGraphBreadthFirstIterator<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 |
DanDirectedGraphBreadthFirstIterator<I, D>
Throws
exception if startingNodeId was not found in graph
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:36
• Private _currLevelQueue: DanNode<I, D>[]
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:22
• Private _currLevelQueuePosition: number
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:24
• Private _currentNodeId: null | I
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:18
• Private _graph: DanDirectedGraph<I, D>
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:12
• Private _nextLevelQueue: DanNode<I, D>[]
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:26
• Private _nextLevelSet: Set<I>
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:28
• Private _nextNodeId: null | I
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:20
• Private _startingNodeId: I
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:16
• Private _visitedNodes: Set<I>
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:14
▸ _addNextNodeOutgoingsToNextLevelQueueIfNotAlreadyVisitedOrQueued(): boolean
Add the outgoing nodes of this._nextNodeId to the next-level-queue, if the node was not already visited, and if it's not already present inside the queue
boolean
true if this._nextNodeId is not null, otherwise false
Throws
exception if this._nextNodeId was not found in graph
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:116
▸ _advance(): void
Advance to the next node in a breadth first fashion
void
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:137
▸ _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/danDirectedGraphBreadthFirstIterator.ts:51
▸ _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/danDirectedGraphBreadthFirstIterator.ts:64
▸ 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/danDirectedGraphBreadthFirstIterator.ts:81
▸ 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/danDirectedGraphBreadthFirstIterator.ts:173
▸ 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/danDirectedGraphBreadthFirstIterator.ts:94
▸ rewind(): void
Restart the iterator
void
src/directed_graph/danDirectedGraphBreadthFirstIterator.ts:180