Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/baifei2014/pathfinding
pathfinding library about dijkstra and a_star algorithm
https://github.com/baifei2014/pathfinding
Last synced: 11 days ago
JSON representation
pathfinding library about dijkstra and a_star algorithm
- Host: GitHub
- URL: https://github.com/baifei2014/pathfinding
- Owner: baifei2014
- Created: 2023-10-23T11:48:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-24T02:40:31.000Z (about 1 year ago)
- Last Synced: 2023-10-24T12:39:28.620Z (about 1 year ago)
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
pathfinding library about dijkstra and a_star algorithm
## Examples
The following are demonstration examples of two algorithms
### Dijkstra
#### first step
- generate graph
- define start, goal
- define cost of cost so far and shortest path by came from```go
graph := implementions.MakeDiagram4()start := implementions.Location{X: 1, Y: 4}
goal := implementions.Location{X: 8, Y: 5}came_from := map[implementions.Location]implementions.Location{}
cost_so_far := map[implementions.Location]int{}
```#### second step
- do search
- construct path```go
implementions.DijkstraSearch(graph, start, goal, came_from, cost_so_far)path := implementions.ReconstructPath(start, goal, came_from)
```#### third step
- draw path on graph
```go
implementions.DrawGrid(graph, path)
```### A_Star|A*
#### first step
- generate graph
- define start, goal
- define cost of cost so far and shortest path by came from```go
graph := implementions.MakeDiagram4()start := implementions.Location{X: 1, Y: 4}
goal := implementions.Location{X: 8, Y: 5}came_from := map[implementions.Location]implementions.Location{}
cost_so_far := map[implementions.Location]int{}
```#### second step
- do search
- construct path```go
implementions.AStarSearch(graph, start, goal, came_from, cost_so_far)path := implementions.ReconstructPath(start, goal, came_from)
```#### third step
- draw path on graph
```go
implementions.DrawGrid(graph, path)
```