Documentation
¶
Index ¶
- type BinaryHeap
- type CompareFunc
- type Edge
- type EdgeList
- type Graph
- func (g *Graph[TValue]) AStar(start, end *Node[TValue], h func(n *Node[TValue]) float64) (NodeList[TValue], error)
- func (g *Graph[TValue]) AddEdge(from, to *Node[TValue], distance float64) *Edge[TValue]
- func (g *Graph[TValue]) AddNode(value TValue) *Node[TValue]
- func (g *Graph[TValue]) BellmanFord(source *Node[TValue]) (Predecessors[TValue], error)
- func (g *Graph[TValue]) Dijkstra(source *Node[TValue]) (Predecessors[TValue], error)
- func (g *Graph[TValue]) Size() int
- func (g Graph[TValue]) ToDot(value func(TValue) string) (string, error)
- type Node
- type NodeList
- type Predecessors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinaryHeap ¶
type BinaryHeap[TValue any] struct { Tree []TValue Comparator CompareFunc[TValue] }
func NewBinaryHeap ¶
func NewBinaryHeap[TValue any](cmp CompareFunc[TValue]) *BinaryHeap[TValue]
func (*BinaryHeap[TValue]) Contains ¶
func (h *BinaryHeap[TValue]) Contains(valueToFind TValue, cmp CompareFunc[TValue]) bool
func (*BinaryHeap[TValue]) Head ¶
func (h *BinaryHeap[TValue]) Head() (TValue, bool)
func (*BinaryHeap[TValue]) Pop ¶
func (h *BinaryHeap[TValue]) Pop() (TValue, bool)
Pop head (root) value
func (*BinaryHeap[TValue]) Push ¶
func (h *BinaryHeap[TValue]) Push(value TValue)
Push value to the heap
func (*BinaryHeap[TValue]) Size ¶
func (h *BinaryHeap[TValue]) Size() int
type CompareFunc ¶
type Graph ¶
func (*Graph[TValue]) BellmanFord ¶
func (g *Graph[TValue]) BellmanFord(source *Node[TValue]) (Predecessors[TValue], error)
type Predecessors ¶
Look up table to find a node's predecessor Key: Node.Id of node A Value: *Node of node B Result: Edge from node A to node B
func (Predecessors[TValue]) Get ¶
func (p Predecessors[TValue]) Get(node *Node[TValue]) *Node[TValue]
func (Predecessors[TValue]) GetShortestPath ¶
func (p Predecessors[TValue]) GetShortestPath(nodeEnd *Node[TValue]) NodeList[TValue]
Get the longest shortest path from starting node to nodeEnd
func (Predecessors[TValue]) Set ¶
func (p Predecessors[TValue]) Set(from, to *Node[TValue])
Click to show internal directories.
Click to hide internal directories.