ParallelGraphAlgorithmContext

public struct ParallelGraphAlgorithmContext<
  Graph,  // : GraphProtocol,  // Redundant conformance.
  Message,
  GlobalState: MergeableMessage,
  Mailbox: MailboxProtocol
> where Mailbox.Message == Message, Mailbox.Graph == Graph

Context provided to the function that is invoked on a per-vertex basis.

We use a context object to (1) simplify the parallel graph API, and (2) make it easy to extend the parallel graph implementation if new bits of context need to be added over time.

ParallelGraphAlgorithmContext also helps enforce the inability to access Vertex property maps during the course of execution, as that could result in violations of the Law of Exclusivity.

See also

ParalleGraph
  • The identifier of the vertex this function execution is operating upon.

    Declaration

    Swift

    public let vertex: Graph.VertexId
  • The global state provided to each vertex.

    This global state is often computed as a result of merging the computed global state from each vertex in the previous super-step, although it is provided by the user-program for the first step.

    Declaration

    Swift

    public let globalState: GlobalState
  • Initializes self with the given properties.

    Declaration

    Swift

    public init(
      vertex: Graph.VertexId,
      globalState: GlobalState,
      graph: Graph,
      mailbox: UnsafeMutablePointer<Mailbox>
    )
  • The merged message resulting from merging all the messages sent in the last parallel step.

    Declaration

    Swift

    public var inbox: Message? { get }
  • Sends message to vertex, which will be received at the next step.

    Declaration

    Swift

    public mutating func send(_ message: Message, to vertex: Graph.VertexId)
  • Retrieve edge propreties.

    Declaration

    Swift

    public func getEdgeProperty<Map: ParallelCapablePropertyMap>(
      for edge: Graph.EdgeId,
      in map: Map
    ) -> Map.Value where Map.Graph.ParallelProjection == Graph, Map.Key == Graph.EdgeId

Available where Graph: IncidenceGraph

  • The number of edges that source from the current vertex.

    Declaration

    Swift

    public var outDegree: Int { get }
  • The edges that source from the current vertex.

    Declaration

    Swift

    public var edges: Graph.VertexEdgeCollection { get }
  • Returns the destination of edge.

    Declaration

    Swift

    public func destination(of edge: Graph.EdgeId) -> Graph.VertexId