astar

package
v0.0.0-...-efbb552 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrImpossible = errors.New("astar: no path exists between start and end")

Functions

This section is empty.

Types

type Debug

type Debug interface {
	VisitedNode(node, parentNode Node, currentCost, predictedCost float64)
}

type Edge

type Edge struct {
	Node Node    // destination node
	Cost float64 // cost to move to the node
}

type Graph

type Graph interface {
	// Edges is passed in for reuse. This method gets called a large number of times
	// so we don't want to allocate an Edge slice for every call.
	Neighbors(node Node, edges []Edge) ([]Edge, error)
	HeuristicCost(start, end Node) (float64, error)
}

type Node

type Node int64

func FindPath

func FindPath(mp Graph, start, end Node) ([]Node, error)

Find the optimal path through the graph from start to end and return the nodes in order for the path. If no path is found because it's impossible to reach end from start then return an error.

type PossiblePath

type PossiblePath interface {
	PossiblePath(path []Node, cost float64)
}

If a graph implementation implements the PossiblePath interface then it can receive intermediate results before the algorithms converges on an optimal path.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL