WeightedGraph

public struct WeightedGraph <Node: Hashable, Weight>:
    WeightedGraphProtocol,
    UndirectedGraphProtocol
extension WeightedGraph: Equatable where Weight: Equatable
extension WeightedGraph: Hashable where Weight: Hashable

Weighted, undirected graph.

Instance Properties

  • All of the nodes contained herein.

    A Node is any Hashable-conforming value.

    Declaration

    Swift

    public var nodes: Set<Node>
  • All of the edges contained herein stored with their weight.

    An Edge is an UnorderedPair of Node values, and a Weight is any AdditiveGroup-conforming value.

    Declaration

    Swift

    public var weights: [Edge : Weight]

Type Aliases

  • The type of edges which connect nodes.

    Declaration

    Swift

    public typealias Edge = UnorderedPair<Node>

Initializers

  • Creates a Graph with the given set of nodes, with no edges between the nodes.

    Declaration

    Swift

    @inlinable
    public init(_ nodes: Set<Node> = [])
  • Creates a Graph with the given set of nodes and the given dictionary of weights stored by the applicable edge.

    Declaration

    Swift

    @inlinable
    public init(_ nodes: Set<Node> = [], _ weights: [Edge : Weight] = [:])
  • Creates a WeightedGraph with enough memory to store the given minimumNodesCapacity and minimumEdgesCapacity.

    Declaration

    Swift

    public init(minimumNodesCapacity: Int, minimumEdgesCapacity: Int)