Documentation ¶
Index ¶
- type CyclicError
- type Graph
- func (g *Graph[T]) AddChild(parentID string, childID string) error
- func (g *Graph[T]) AddEdge(fromID string, toID string) error
- func (g *Graph[T]) Clone() *Graph[T]
- func (g *Graph[T]) GetNextLeaf(start *Node[T]) *Node[T]
- func (g *Graph[T]) InsertNodeAt(parentID string, id string, data T) (*Node[T], error)
- func (g *Graph[T]) NextFromTop() *Node[T]
- func (g *Graph[T]) RemoveNode(id string) error
- func (g *Graph[T]) RemoveSubGraph(id string) error
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CyclicError ¶
type CyclicError[T comparable] struct { What string // contains filtered or unexported fields }
CyclicError is the type that is returned if a cyclic edge would be inserted
func (*CyclicError[T]) Error ¶
func (c *CyclicError[T]) Error() string
Error implements error interface
type Graph ¶
type Graph[T comparable] struct { Nodes map[string]*Node[T] Root *Node[T] // contains filtered or unexported fields }
func NewGraph ¶
func NewGraph[T comparable](root *Node[T]) *Graph[T]
func NewGraphOf ¶
func NewGraphOf[T comparable](root *Node[T], item string) *Graph[T]
func (*Graph[T]) AddEdge ¶
AddEdge adds a new edge from a node to a node and returns an error if it would result in a cyclic graph
func (*Graph[T]) GetNextLeaf ¶
GetNextLeaf returns the next leaf in the graph from node start
func (*Graph[T]) InsertNodeAt ¶
InsertNodeAt inserts a new node at the given parent position
func (*Graph[T]) NextFromTop ¶ added in v0.3.4
func (*Graph[T]) RemoveNode ¶
RemoveNode removes a node with no children in the graph
func (*Graph[T]) RemoveSubGraph ¶ added in v0.3.4
Click to show internal directories.
Click to hide internal directories.