GraphIteratorBFS

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

Signature

const iterator = new GraphIteratorBFS(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