dag

package
v0.0.0-...-0d27ab4 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any[T INode](g *Graph, predicates ...Filter[T]) T

func ByID

func ByID[T INode](g *Graph, id string) T

Types

type CNode

type CNode struct {
	Node     INode
	Outgoing []INode
	Incoming []INode
}

type Comparable

type Comparable struct {
	Nodes []INode
	Edges [][2]int
}

type Edge

type Edge struct {
	From INode
	To   INode
}

type Filter

type Filter[T INode] func(T) bool

type Graph

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

func New

func New(clone func(INode) INode) *Graph

func (*Graph) AddEdge

func (g *Graph) AddEdge(from, to INode)

func (*Graph) AddNode

func (g *Graph) AddNode(id string, n INode) INode

func (*Graph) ByID

func (g *Graph) ByID(id string) INode

func (*Graph) Comparable

func (g *Graph) Comparable() []CNode

func (*Graph) String

func (g *Graph) String() string

type INode

type INode interface {
	// contains filtered or unexported methods
}

type Node

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

Node implements INode and should be embedded into structs that will be added to a Graph. Usage:

type Entity struct {
	dag.Node
	Attribute string
}

type Result

type Result[T INode] []T

func Incoming

func Incoming[T INode](n INode, predicates ...Filter[T]) Result[T]

func Nodes

func Nodes[T INode](g *Graph, predicates ...Filter[T]) Result[T]

func Outgoing

func Outgoing[T INode](n INode, predicates ...Filter[T]) Result[T]

func (Result[T]) All

func (q Result[T]) All(predicates ...func(T) bool) []T

func (Result[T]) Any

func (q Result[T]) Any() T

func (Result[T]) One

func (q Result[T]) One() T

func (Result[T]) Pick

func (q Result[T]) Pick(n int) []T

Pick a random selection of exactly n elements. Panics if there are less than n total elements.

func (Result[T]) PickBetween

func (q Result[T]) PickBetween(min, max int) []T

func (Result[T]) PickUpTo

func (q Result[T]) PickUpTo(n int) []T

Jump to

Keyboard shortcuts

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