GraphProtocol
public protocol GraphProtocol
Interface for graph-like tyes.
-
The type of nodes contained herein.
Declaration
Swift
associatedtype Node : Hashable where Self.Node == Self.Edge.A
-
The type of edges contained herein.
Declaration
Swift
associatedtype Edge : SymmetricPair, Hashable
-
remove(_:
Default implementation) Removes
edge
from graph.Default Implementation
Removes the given
node
and removes all edges that contain it.Declaration
Swift
mutating func remove(_ edge: Edge)
-
insert(_:
Extension method) Inserts the given
node
without making any connections to other nodes contained herein.Declaration
Swift
@inlinable public mutating func insert(_ node: Node)
-
removeEdge(from:
Extension methodto: ) -
contains(_:
Extension method) Declaration
Swift
@inlinable public func contains(_ node: Node) -> Bool
Return Value
true
if theGraphProtocol
-conforming type value contains the givennode
. Otherwise,false
. -
containsEdge(from:
Extension methodto: ) -
contains(_:
Extension method) Returns:
true
if theGraphProtocol
-conforming type value contains the givenedge
. Otherwise,false
.Declaration
Swift
@inlinable public func contains(_ edge: Edge) -> Bool
-
neighbors(of:
Extension methodin: ) -
edges(from:
Extension method) -
edges(to:
Extension method) -
breadthFirstSearch(from:
Extension methodto: ) -
shortestUnweightedPath(from:
Extension methodto: ) In the case that there are more than one paths from the given
source
to the givendestination
, the path with the fewest edges is returned.Declaration
Return Value
An array of
Node
values from the givensource
to the givendestination
.