GraphNode
public protocol GraphNode : Graph, Hashable
A simplified version of the Graph protocol that allows optimal path finding between nodes without the need of a containing Graph type.
Use this protocol instead of Graph if your nodes store their outgoing edges.
When your nodes do not store edge information, consider using the Graph protocol.
-
In a
GraphNodeGraphthe nodes are of typeGraphNode.Declaration
Swift
associatedtype Node = Self
-
List of other graph nodes that this node has an edge leading to.
Declaration
Swift
var connectedNodes: Set<Self> { get } -
Returns the estimated/heuristic cost to reach the indicated node from this node
Declaration
Swift
func estimatedCost(to node: Self) -> FloatParameters
nodethe end point of the edge who’s cost is to be estimated
Return Value
the heuristic cost
-
Declaration
Swift
func cost(to node: Self) -> FloatParameters
nodethe destination node
Return Value
the actual cost to reach the indicated node from this node
-
nodesAdjacent(to:Extension method) -
estimatedCost(from:Extension methodto: ) -
cost(from:Extension methodto: )
-
findPath(to:Extension method) Attempts to find the optimal path between this node and the indicated goal node. If such a path exists, it is returned in start to end order. If it doesn’t exist, the returned array will be empty.
Declaration
Swift
public func findPath(to goalNode: Self) -> [Self]Parameters
goalNodethe goal node of the pathfinding attempt
Return Value
the optimal path between this node and the indicated goal node
-
findPath(from:Extension method) As with findPathToNode: except this node is the goal node and a startNode is specified
Declaration
Swift
public func findPath(from startNode: Self) -> [Self]Parameters
startNodethe start node of the pathfinding attempt
Return Value
the optimal path between the indicated start node and this node
View on GitHub
GraphNode Protocol Reference