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 graph gathered in a breadth-first manner from root.

    Declaration

    Swift

    public init(from root: Vertex, in graph: DirectedGraph<Vertex, Label>)
  • Returns the next vertex, or nil if all vertices have been returned already.

    Declaration

    Swift

    public mutating func next() -> Vertex?