dag

package
v2.0.5-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrVertexNotFound represents vertex not found.
	ErrVertexNotFound = errors.New("vertex not found")

	// ErrVertexAlreadyExists represents vertex already exists.
	ErrVertexAlreadyExists = errors.New("vertex already exists")

	// ErrParnetAlreadyExists represents parent of vertex already exists.
	ErrParnetAlreadyExists = errors.New("parent of vertex already exists")

	// ErrChildAlreadyExists represents child of vertex already exists.
	ErrChildAlreadyExists = errors.New("child of vertex already exists")

	// ErrCycleBetweenVertices represents cycle between vertices.
	ErrCycleBetweenVertices = errors.New("cycle between vertices")
)

Functions

This section is empty.

Types

type DAG

type DAG interface {
	// AddVertex adds vertex to graph.
	AddVertex(id string, value any) error

	// DeleteVertex deletes vertex graph.
	DeleteVertex(id string)

	// GetVertex gets vertex from graph.
	GetVertex(id string) (*Vertex, error)

	// AddEdge adds edge between two vertices.
	AddEdge(fromVertexID, toVertexID string) error

	// DeleteEdge deletes edge between two vertices.
	DeleteEdge(fromVertexID, toVertexID string) error
}

DAG is the interface used for directed acyclic graph.

func NewDAG

func NewDAG() DAG

New returns a new DAG interface.

type Vertex

type Vertex struct {
	ID       string
	Value    any
	Parents  set.SafeSet
	Children set.SafeSet
}

Vertex is a vertex of the directed acyclic graph.

func NewVertex

func NewVertex(id string, value any) *Vertex

New returns a new Vertex instance.

func (*Vertex) Degree

func (v *Vertex) Degree() int

Degree returns the degree of vertex.

func (*Vertex) InDegree

func (v *Vertex) InDegree() int

InDegree returns the indegree of vertex.

func (*Vertex) OutDegree

func (v *Vertex) OutDegree() int

OutDegree returns the outdegree of vertex.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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