Documentation
¶
Overview ¶
Package dijkstra is an highly optimised implementation of the Dijkstra algorithm, used for find the shortest path between points of a graph.
A graph is a map of points and map to the neighbouring points in the graph and the cost to reach them. A trivial example of a graph definition is:
Graph{ "a": {"b": 10, "c": 20}, "b": {"a": 50}, "c": {"b": 10, "a": 25}, }
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
Graph is a rappresentation of how the points in our graph are connected between each other
func (Graph) Path ¶
Path finds the shortest path between start and target, also returning the total cost of the found path.
Example ¶
g := Graph{ "a": {"b": 20, "c": 80}, "b": {"a": 20, "c": 20}, "c": {"a": 80, "b": 20}, } path, cost, _ := g.Path("a", "c") // skipping error handling fmt.Printf("path: %v, cost: %v", path, cost)
Output: path: [a b c], cost: 40
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a basic priority queue implementation, where the node with the lowest priority is kept as first element in the queue
Click to show internal directories.
Click to hide internal directories.