Versions in this module Expand all Collapse all v1 v1.0.0 Jul 31, 2026 Changes in this version + var ErrDAGCycle = errors.New("edges would create cycle") + var ErrDAGHasCycle = errors.New("the graph contains a cycle") + var ErrEdgeAlreadyExists = errors.New("edge already exists") + var ErrNilVertices = errors.New("vertices are nil") + var ErrVertexDoesNotExist = errors.New("vertex does not exist") + type Edge struct + func NewEdge[T comparable](source *Vertex[T], dest *Vertex[T], options ...EdgeOptionFunc) *Edge[T] + func (e *Edge[T]) Destination() *Vertex[T] + func (e *Edge[T]) OtherVertex(v T) *Vertex[T] + func (e *Edge[T]) Source() *Vertex[T] + func (e *Edge[T]) Weight() float64 + func (e Edge[T]) Metadata() any + type EdgeOptionFunc func(properties *EdgeProperties) + func WithEdgeWeight(weight float64) EdgeOptionFunc + type EdgeProperties struct + type Graph interface + AddEdge func(from, to *Vertex[T], options ...EdgeOptionFunc) (*Edge[T], error) + AddVertex func(v *Vertex[T]) + AddVertexByLabel func(label T, options ...VertexOptionFunc) *Vertex[T] + AllEdges func() []*Edge[T] + ContainsEdge func(from, to *Vertex[T]) bool + ContainsVertex func(v *Vertex[T]) bool + EdgesOf func(v *Vertex[T]) []*Edge[T] + GetAllEdges func(from, to *Vertex[T]) []*Edge[T] + GetAllVertices func() []*Vertex[T] + GetAllVerticesByID func(label ...T) []*Vertex[T] + GetEdge func(from, to *Vertex[T]) *Edge[T] + GetVertexByID func(label T) *Vertex[T] + Order func() uint32 + RemoveEdges func(edges ...*Edge[T]) + RemoveVertices func(removeEdges bool, vertices ...*Vertex[T]) + Size func() uint32 + func New[T comparable](options ...GraphOptionFunc) Graph[T] + type GraphOptionFunc func(properties *GraphProperties) + func Acyclic() GraphOptionFunc + func Directed() GraphOptionFunc + func Weighted() GraphOptionFunc + type GraphProperties struct + type GraphType interface + IsAcyclic func() bool + IsDirected func() bool + IsWeighted func() bool + type Vertex struct + func NewVertex[T comparable](label T, options ...VertexOptionFunc) *Vertex[T] + func TopologySort[T comparable](g Graph[T]) ([]*Vertex[T], error) + func (v *Vertex[T]) Degree() int + func (v *Vertex[T]) HasNeighbor(vertex *Vertex[T]) bool + func (v *Vertex[T]) InDegree() int + func (v *Vertex[T]) Label() T + func (v *Vertex[T]) Metadata() any + func (v *Vertex[T]) NeighborByLabel(label T) *Vertex[T] + func (v *Vertex[T]) Neighbors() []*Vertex[T] + func (v *Vertex[T]) OutDegree() int + func (v *Vertex[T]) Weight() float64 + type VertexOptionFunc func(properties *VertexProperties) + func WithVertexWeight(weight float64) VertexOptionFunc + type VertexProperties struct