depgraph

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

README

Experimental Dependency Graph Implementation

Inspired by https://github.com/jriecken/dependency-graph.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph struct {
	// contains filtered or unexported fields
}

Graph implements a simple dependency graph.

func New

func New() *Graph

New returns a new, empty dependency graph.

func (*Graph) AddDependency

func (g *Graph) AddDependency(from, to string) error

AddDependency adds a dependency between two nodes. If either node doesn't exist an error is returned.

func (*Graph) AddNode

func (g *Graph) AddNode(s string)

AddNode adds the specified string to the graph.

func (*Graph) DependenciesOf

func (g *Graph) DependenciesOf(s string) ([]string, error)

DependenciesOf returns the nodes that the specified node depends on (transitively). Returns an error if the specified node doesn't exist or a dependency cycle is detected.

func (*Graph) DependentsOf

func (g *Graph) DependentsOf(s string) ([]string, error)

DependentsOf returns the nodes that depend on the specified node (transitively). Returns an error if the specified node doesn't exist or a dependency cycle is detected.

func (*Graph) DirectDependenciesOf

func (g *Graph) DirectDependenciesOf(s string) ([]string, error)

DirectDependenciesOf returns the nodes that are the direct dependencies of the specified node. Returns an error if the specified node doesn't exist.

func (*Graph) DirectDependentsOf

func (g *Graph) DirectDependentsOf(s string) ([]string, error)

DirectDependentsOf returns the nodes that directly depend on the specified node. Returns an error if the specified node doesn't exist.

func (*Graph) HasNode

func (g *Graph) HasNode(s string) bool

HasNode returns whether the specified string is in the graph.

func (*Graph) Len

func (g *Graph) Len() int

Len returns the number of nodes in the graph.

func (*Graph) OverallOrder

func (g *Graph) OverallOrder() ([]string, error)

OverallOrder returns the overall processing order for the dependency graph. Returns an error if a dependency cycle is detected.

func (*Graph) RemoveDependency

func (g *Graph) RemoveDependency(from, to string)

RemoveDependency removes a dependency between two nodes. If either node doesn't exist no error is returned.

func (*Graph) RemoveNode

func (g *Graph) RemoveNode(s string)

RemoveNode removes the specified string from the graph if it is present.

Jump to

Keyboard shortcuts

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