Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoPath = errors.New("no path exists")
Functions ¶
func ShortestPath ¶
ShortestPath returns the shortest path from 0 to n. ErrNoPath is returned if there is no path from start to a vertex >= end. Otherwise, the path is returned as a slice of edges.
func ShortestPathDyn ¶
func ShortestPathDyn[vertex Beforer[vertex], edge E, length L](g DynamicGraph[vertex, edge, length], start, end vertex) ([]edge, error)
ShortestPathDyn returns the shortest path from start to a vertex >= end. ErrNoPath is returned if there is no path from start to a vertex >= end. Otherwise, the path is returned as a slice of edges.
Types ¶
type DynamicGraph ¶
type DynamicGraph[vertex Beforer[vertex], edge E, length L] interface { // AppendEdges appends the outgoing edges of the given vertex to a slice. // All edges must lead to vertices with index strictly greater than v. AppendEdges(ee []edge, v vertex) []edge // Length returns the length of edge e starting at vertex v. Length(v vertex, e edge) length // To returns the endpoint of an edge e starting at vertex v. To(v vertex, e edge) vertex }
Graph represents a directed acyclic graph.
type Graph ¶
type Graph[edge E, length L] interface { // AppendEdges appends the outgoing edges of the given vertex to a slice. // All edges must lead to vertices with index strictly greater than v. AppendEdges(ee []edge, v int) []edge // Length returns the length of edge e starting at vertex v. Length(v int, e edge) length // To returns the endpoint of an edge e starting at vertex v. To(v int, e edge) int }
Graph represents a directed acyclic graph.
Click to show internal directories.
Click to hide internal directories.