Documentation
¶
Index ¶
- func NextId() int
- type BaseNode
- type Graph
- func (g *Graph[ID]) AddDirectedEdge(from, to ID, weight int)
- func (g *Graph[ID]) AddEdge(a, b ID, weight int)
- func (g *Graph[ID]) AddNode(node Node[ID])
- func (g Graph[ID]) Dfs(start Node[ID], goal func(ID) bool) Path[ID]
- func (g Graph[ID]) Dijkstra(start Node[ID], goal func(ID) bool) Path[ID]
- func (g Graph[ID]) Distances(start Node[ID]) map[ID]int
- func (g *Graph[ID]) GetNode(id ID) Node[ID]
- func (g *Graph[ID]) GetNodes() map[ID]Node[ID]
- func (g *Graph[ID]) HasNode(id ID) bool
- func (g Graph[ID]) NodesOfBestPaths(start Node[ID], goal func(ID) bool) []ID
- func (g *Graph[ID]) RemoveNode(id ID)
- func (g *Graph[ID]) String() string
- type Node
- type Path
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseNode ¶
type BaseNode[T comparable] struct { // contains filtered or unexported fields }
func NewBaseNode ¶
func NewBaseNode[T comparable](id T) *BaseNode[T]
func NewBaseNodeAutoId ¶
func (*BaseNode[T]) AddNeighbor ¶
func (*BaseNode[T]) GetNeighbors ¶
func (*BaseNode[T]) HasNeighbor ¶
func (*BaseNode[T]) RemoveNeighbor ¶
func (n *BaseNode[T]) RemoveNeighbor(id T)
type Graph ¶
type Graph[ID comparable] struct { // contains filtered or unexported fields }
func New ¶
func New[ID comparable]() *Graph[ID]
func (*Graph[ID]) AddDirectedEdge ¶
func (Graph[ID]) Dfs ¶
Dfs finds the shortest path from the start node to the end node using depth-first search
func (Graph[ID]) Distances ¶
Distances finds the shortest path from the start node to all other nodes
func (Graph[ID]) NodesOfBestPaths ¶
NodesOfBestPaths finds all the shortest paths from the start node to the end node
func (*Graph[ID]) RemoveNode ¶
func (g *Graph[ID]) RemoveNode(id ID)
type Path ¶
type Path[ID comparable] struct { // contains filtered or unexported fields }
func NewPath ¶
func NewPath[ID comparable](nodes []ID, cost int) Path[ID]
func NoPath ¶
func NoPath[ID comparable]() Path[ID]
func (*Path[ID]) AddFirstNode ¶
Click to show internal directories.
Click to hide internal directories.