Skip to content

GraphIteratorDFS ​

Guide: /guide/algorithms/graph/iterator-dfs

Signature ​

ts
const iterator = new GraphIteratorDFS(graph);

Params: ​

NameTypeRequiredDefaultDescription
graphIGraph<T>+Given graph

Returns: ​

IGraphIterator<T> ​


Iterator methods: ​

initIterator(from: T): void ​

Init iterator by passing 'from' vertex

Params: ​
NameTypeRequiredDefaultDescription
fromT+Start vertex
Throws IsNotFoundException when there is no next element ​



next(): T ​

Iterate to next element (depends on iteration strategy)

Throws IllegalStateException when there is no next element ​



current(): T ​

Get current element

Throws IllegalStateException when there is no current element ​



hasNext(): boolean ​

Check is there next element available

getPath(from: T, to: T): Array<T> ​

Get full path between two given vertices

Params: ​
NameTypeRequiredDefaultDescription
fromT+Start vertex
toT+End vertex
Throws IllegalStateException when there is no path at all ​



MIT Licensed