mirror of
https://github.com/gonum/gonum.git
synced 2025-10-28 17:31:56 +08:00
Added way to sort nodes
This commit is contained in:
@@ -142,6 +142,20 @@ func (pq *aStarPriorityQueue) Exists(id int) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
type denseNodeSorter []gr.Node
|
||||
|
||||
func (dns denseNodeSorter) Less(i, j int) bool {
|
||||
return dns[i].ID() < dns[j].ID()
|
||||
}
|
||||
|
||||
func (dns denseNodeSorter) Swap(i, j int) {
|
||||
dns[i], dns[j] = dns[j], dns[i]
|
||||
}
|
||||
|
||||
func (dns denseNodeSorter) Len() int {
|
||||
return len(dns)
|
||||
}
|
||||
|
||||
// General utility funcs
|
||||
|
||||
// Rebuilds a path backwards from the goal.
|
||||
|
||||
Reference in New Issue
Block a user