Help us shape the future of Go! Take the 2026 Go Developer Survey

graph

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph[T comparable] struct {
	// contains filtered or unexported fields
}

func NewGraph

func NewGraph[T comparable]() *Graph[T]

func (*Graph[T]) AddEdge

func (g *Graph[T]) AddEdge(from, to string) error

func (*Graph[T]) AddNode

func (g *Graph[T]) AddNode(id string, data T) error

AddNode adds a node to the graph with the given ID and data. Returns an error if a node with the same ID already exists.

func (*Graph[T]) AddNodes

func (g *Graph[T]) AddNodes(nodes map[string]T) error

AddNodes adds multiple nodes to the graph. Returns an error if any node with the same ID already exists.

func (*Graph[T]) EdgeCount

func (g *Graph[T]) EdgeCount() int

func (*Graph[T]) GetChildren

func (g *Graph[T]) GetChildren(id string) []string

func (*Graph[T]) GetNode

func (g *Graph[T]) GetNode(id string) (T, bool)

func (*Graph[T]) GetNodes

func (g *Graph[T]) GetNodes() map[string]T

func (*Graph[T]) GetParents

func (g *Graph[T]) GetParents(id string) []string

func (*Graph[T]) HasCircularDependency

func (g *Graph[T]) HasCircularDependency() bool

func (*Graph[T]) HasEdge

func (g *Graph[T]) HasEdge(from, to string) bool

func (*Graph[T]) HasNode

func (g *Graph[T]) HasNode(id string) bool

func (*Graph[T]) IsEmpty

func (g *Graph[T]) IsEmpty() bool

func (*Graph[T]) NodeCount

func (g *Graph[T]) NodeCount() int

func (*Graph[T]) RemoveChildren

func (g *Graph[T]) RemoveChildren(id string) error

func (*Graph[T]) RemoveEdge

func (g *Graph[T]) RemoveEdge(from, to string) error

func (*Graph[T]) RemoveNode

func (g *Graph[T]) RemoveNode(id string) error

func (*Graph[T]) RemoveSubGraph

func (g *Graph[T]) RemoveSubGraph(id string) error

func (*Graph[T]) SetNode

func (g *Graph[T]) SetNode(id string, data T) error

func (*Graph[T]) Sort

func (g *Graph[T]) Sort() ([]T, error)

func (*Graph[T]) SortNodeIDs

func (g *Graph[T]) SortNodeIDs() ([]string, error)

func (*Graph[T]) String

func (g *Graph[T]) String() string

func (*Graph[T]) UpdateNode

func (g *Graph[T]) UpdateNode(id string, data T) error

Jump to

Keyboard shortcuts

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