WeightedGraphProtocol
public protocol WeightedGraphProtocol : GraphProtocol
Interface for weighted graphs.
-
The type of the weight of an
Edge
.Declaration
Swift
associatedtype Weight
-
The storage of weights by the applicable edge.
Declaration
Swift
var weights: [Edge : Weight] { get set }
-
unweighted()
Extension methodDeclaration
Swift
@inlinable public func unweighted<U>() -> U where U : UnweightedGraphProtocol, Self.Edge == U.Edge
Return Value
An unweighted version of this
WeightedGraphProtocol
-conforming type value.
-
edges
Extension methodDeclaration
Swift
@inlinable public var edges: Set<Edge> { get }
Return Value
All of the edges contained herein.
-
weight(from:
Extension methodto: ) Declaration
Swift
@inlinable public func weight(from source: Node, to destination: Node) -> Weight?
Return Value
The weight for the edge connecting the given
source
anddestination
nodes, if the givenedge
is contained herein. Otherwise,nil
. -
weight(_:
Extension method) Declaration
Swift
@inlinable public func weight(_ edge: Edge) -> Weight?
Return Value
The weight for the given
edge
, if the givenedge
is contained herein. Otherwise,nil
.
-
insertEdge(from:
Extension methodto: weight: ) Inserts an edge between the given
source
anddestination
nodes, with the givenweight
.If the
source
ordestination
nodes are not yet contained herein, they are inserted.Declaration
Swift
@inlinable public mutating func insertEdge(from source: Node, to destination: Node, weight: Weight)
-
remove(_:
Extension method) Remove
edge
from graph.Declaration
Swift
@inlinable public mutating func remove(_ edge: Edge)
-
insertEdge(_:
Extension methodweight: ) Inserts the given
edge
with the givenweight
.Declaration
Swift
@inlinable public mutating func insertEdge(_ edge: Edge, weight: Weight)
-
updateEdge(from:
Extension methodto: by: ) -
updateEdge(_:
Extension methodby: )