graph

package
v0.0.0-...-544f500 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2024 License: CC0-1.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dijkstras

func Dijkstras[T any, W EdgeWeight](g Graph[T, W], source, target int, limit int) ([][]int, W)

Dijkstra finds the shortest paths from source to target and returns it as well as its weight.

Types

type EdgeWeight

type EdgeWeight interface {
	int | float64
}

type Graph

type Graph[T any, W EdgeWeight] struct {
	Points []T
	Edges  map[int]map[int]W
}

A Graph is a network of points of type T and weighted, directed edges between them. Edges are represented by pairs of indexes into the Points slice. An undirected edge is represented as a symmetric pair of edges.

func NewUndirectedGraph

func NewUndirectedGraph[T any, W EdgeWeight](points []T, edges map[[2]int]W) Graph[T, W]

func (*Graph[T, W]) NEdges

func (gr *Graph[T, W]) NEdges() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL