graph

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2022 License: Apache-2.0 Imports: 5 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

lipence/graph

Package graph provides simple topological opreations for directed / undirected graph.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEdgeConflicts = errors.New("edge conflicts")
View Source
var ErrUndefinedNode = errors.New("undefined node")

Functions

func NewDirected added in v0.0.2

func NewDirected[ID comparable]() *directedGraph[ID]

Types

type Color

type Color uint8
const (
	ColorWhite Color = iota
	ColorGray
	ColorBlack
)

type Graph

type Graph[ID comparable] interface {
	Nodes() []ID
	NodesLen() int
	CheckNode(id ID) bool
	AddNode(id ID) bool
	DeleteNode(id ID) bool
	ChildrenOf(id ID) ([]ID, bool)
	ParentsOf(id ID) ([]ID, bool)
	GetEdge(src, tgt ID) (Weight, bool)
	AddEdge(src, tgt ID, w Weight) error
	SetEdge(src, tgt ID, w Weight) error
	DeleteEdge(src, tgt ID) bool
}

type Runtime

type Runtime[ID comparable] struct {
	// contains filtered or unexported fields
}

func NewRuntime

func NewRuntime[ID comparable](graph Graph[ID]) *Runtime[ID]

func (*Runtime[ID]) DAGSort

func (tr *Runtime[ID]) DAGSort(id ID) ([]ID, error)

func (*Runtime[ID]) DAGSortAll

func (tr *Runtime[ID]) DAGSortAll() ([]ID, error)

type Weight

type Weight uint64

Jump to

Keyboard shortcuts

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