BreadthFirstSequence
public struct BreadthFirstSequence<Vertex, Label> : IteratorProtocol, Sequence where Vertex : Hashable, Vertex : Sendable, Label : Sendable
The vertices of a graph collected in a breadth-first manner.
-
The graph whose the vertices are collected.
Declaration
Swift
public let graph: DirectedGraph<Vertex, Label> -
A queue with vertices to visit.
Declaration
Swift
private var toVisit: Deque<Vertex> -
The vertices that have been returned already.
Declaration
Swift
private var visited: Set<Vertex> -
Creates an instance containing the vertices in
graphgathered in a breadth-first manner fromroot.Declaration
Swift
public init(from root: Vertex, in graph: DirectedGraph<Vertex, Label>) -
Returns the next vertex, or
nilif all vertices have been returned already.Declaration
Swift
public mutating func next() -> Vertex?
View on GitHub