graph

package
v0.19.9 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cycle added in v0.17.4

type Cycle struct {
	Cause [2]string
	Stack []string
}

type Edge added in v0.17.4

type Edge[T any] struct {
	// contains filtered or unexported fields
}

func (*Edge[T]) From added in v0.17.4

func (e *Edge[T]) From() graph.Node

func (*Edge[T]) ReversedEdge added in v0.17.4

func (e *Edge[T]) ReversedEdge() graph.Edge

func (*Edge[T]) To added in v0.17.4

func (e *Edge[T]) To() graph.Node

type EmptyCallbacks added in v0.19.6

type EmptyCallbacks[T any] struct{}

type Graph

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

func MakeTestGraph added in v0.17.4

func MakeTestGraph(spec [][]int) *Graph[int]

func NewGraph

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

func (*Graph[T]) AddFromToEdge added in v0.17.4

func (g *Graph[T]) AddFromToEdge(fromId string, toIds ...string) error

func (*Graph[T]) AddNode

func (g *Graph[T]) AddNode(node *Node[T])

func (*Graph[T]) AllNodes added in v0.17.4

func (g *Graph[T]) AllNodes() []*Node[T]

func (*Graph[T]) Edge added in v0.17.4

func (g *Graph[T]) Edge(uid, vid int64) graph.Edge

func (*Graph[T]) From added in v0.17.4

func (g *Graph[T]) From(id int64) graph.Nodes

func (*Graph[T]) FromId added in v0.17.4

func (g *Graph[T]) FromId(id string) []*Node[T]

FromId returns the nodes to which id can reach.

func (*Graph[T]) Get

func (g *Graph[T]) Get(id string) *Node[T]

func (*Graph[T]) GetNodesWithoutParents added in v0.19.0

func (g *Graph[T]) GetNodesWithoutParents() []*Node[T]

func (*Graph[T]) Has

func (g *Graph[T]) Has(nodeId string) bool

func (*Graph[T]) HasEdgeBetween added in v0.17.4

func (g *Graph[T]) HasEdgeBetween(xid, yid int64) bool

func (*Graph[T]) HasEdgeFromTo added in v0.17.4

func (g *Graph[T]) HasEdgeFromTo(uid, vid int64) bool

func (*Graph[T]) Load added in v0.19.6

func (g *Graph[T]) Load(ids []string, parser NodeParser[T], callbacks LoadCallbacks[T]) error

func (*Graph[T]) Node added in v0.17.4

func (g *Graph[T]) Node(id int64) graph.Node

func (*Graph[T]) Nodes

func (g *Graph[T]) Nodes() graph.Nodes

func (*Graph[T]) RemoveCycles added in v0.17.4

func (g *Graph[T]) RemoveCycles(nodes []*Node[T]) []Cycle

RemoveCycles removes all cycles in the graph, giving preference to cycles that start from the provided nodes.

func (*Graph[T]) RemoveCyclesStartingFromNode added in v0.19.6

func (g *Graph[T]) RemoveCyclesStartingFromNode(node *Node[T]) []Cycle

RemoveCyclesStartingFromNode removes cycles that appear in order while performing a depth first search from a certain node. Note that this may not remove all cycles in the graph.

func (*Graph[T]) RemoveElementaryCycles added in v0.19.6

func (g *Graph[T]) RemoveElementaryCycles() []Cycle

RemoveElementaryCycles removes all the elementary cycles in the graph. The result of this can be non-deterministic.

func (*Graph[T]) RemoveFromToEdge added in v0.17.4

func (g *Graph[T]) RemoveFromToEdge(fromId string, toId string)

func (*Graph[T]) To added in v0.17.4

func (g *Graph[T]) To(id int64) graph.Nodes

func (*Graph[T]) ToId added in v0.17.4

func (g *Graph[T]) ToId(id string) []*Node[T]

ToId returns the nodes from which id is reachable.

type LoadCallbacks added in v0.19.6

type LoadCallbacks[T any] interface {
	// contains filtered or unexported methods
}

type Node

type Node[T any] struct {
	// Id identifies the node with a string. This is typically the absolute path
	//  of a file in dep-tree.
	Id string
	// Errors This node might hold some errors that are worth rendering to the user.
	//  For example, if the node is a file, maybe it failed to be parsed.
	Errors []error
	// Data is a generic implementation-defined data bucket. Implementations can put
	//  whatever they want here.
	Data T
}

func MakeNode

func MakeNode[T any](id string, data T) *Node[T]

func (*Node[T]) AddErrors

func (n *Node[T]) AddErrors(err ...error)

func (*Node[T]) ID added in v0.17.4

func (n *Node[T]) ID() int64

type NodeParser added in v0.19.6

type NodeParser[T any] interface {
	Node(id string) (*Node[T], error)
	Deps(node *Node[T]) ([]*Node[T], error)
}

type NodeParserBuilder added in v0.19.6

type NodeParserBuilder[T any] func([]string) (NodeParser[T], error)

type Nodes added in v0.17.4

type Nodes[T any] struct {
	// contains filtered or unexported fields
}

func NewNodesIterator added in v0.17.4

func NewNodesIterator[T any](nodes []*Node[T]) *Nodes[T]

func (*Nodes[T]) Len added in v0.17.4

func (n *Nodes[T]) Len() int

func (*Nodes[T]) Next added in v0.17.4

func (n *Nodes[T]) Next() bool

func (*Nodes[T]) Node added in v0.17.4

func (n *Nodes[T]) Node() graph.Node

func (*Nodes[T]) Reset added in v0.17.4

func (n *Nodes[T]) Reset()

type StdErrCallbacks added in v0.19.6

type StdErrCallbacks[T any] struct {
	// contains filtered or unexported fields
}

func NewStdErrCallbacks added in v0.19.6

func NewStdErrCallbacks[T any]() *StdErrCallbacks[T]

type TestCallbacks added in v0.19.6

type TestCallbacks[T any] struct {
	// contains filtered or unexported fields
}

type TestParser added in v0.19.6

type TestParser struct {
	Spec [][]int
}

func (*TestParser) Deps added in v0.19.6

func (t *TestParser) Deps(n *Node[[]int]) ([]*Node[[]int], error)

func (*TestParser) Node added in v0.19.6

func (t *TestParser) Node(id string) (*Node[[]int], error)

Jump to

Keyboard shortcuts

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