Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a graph of connected Nodes
func New ¶
New creates a new Graph
nodeNeighbors is a list of neighbors where the index is the node id and the value is that node's neighbors
func (*Graph) FindLevels ¶
FindLevels returns the hop count of each node in the graph
func (*Graph) FindPath ¶
func (g *Graph) FindPath(path *[]Node, maxPathLength int, source, dest Node, priorityFn PriorityFunc)
FindPath finds the shortest path from source to dest
When there are multiple shortest paths, FindPath may return any one of those paths. The first element of the returned path is always source, and the last element is always dest. path - is a pointer to a slice that FindPath will set to the found path When no path is found, path will be set to zero length
func (*Graph) NodeNeighbors ¶
NodeNeighbors returns n's immediate neighbors
type PriorityFunc ¶
PriorityFunc returns a node's priority when choosing between nodes. This is not cost.
The shortest path still wins no matter the priority. Higher number is higher priority. 2 gets chosen before 1.
Click to show internal directories.
Click to hide internal directories.