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
edgefrom graph.Default Implementation
Removes the given
nodeand removes all edges that contain it.Declaration
Swift
mutating func remove(_ edge: Edge) -
insert(_:Extension method) Inserts the given
nodewithout 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) -> BoolReturn Value
trueif theGraphProtocol-conforming type value contains the givennode. Otherwise,false. -
containsEdge(from:Extension methodto: ) -
contains(_:Extension method) Returns:
trueif 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
sourceto the givendestination, the path with the fewest edges is returned.Declaration
Return Value
An array of
Nodevalues from the givensourceto the givendestination.
View on GitHub
Install in Dash
GraphProtocol Protocol Reference