gdsexttree

package module
v0.0.0-...-96dbfd1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph struct {
	Root       []*Node
	NodesIndex map[string]*Node
}

Graph defines the extended tree structure

func (*Graph) AddNode

func (g *Graph) AddNode(n *Node) error

AddNode method includes a new node on the tree

func (*Graph) AddRelationship

func (g *Graph) AddRelationship(parent, child *Node) error

AddRelationship method update the parent-child relationship between two nodes

func (*Graph) DrawGraph

func (g *Graph) DrawGraph(w io.Writer)

DrawGraph method prints the graph

func (*Graph) Exist

func (g *Graph) Exist(n *Node) bool

Exist return if a node already exists on the graph

func (*Graph) GetNode

func (g *Graph) GetNode(nodeName string) (*Node, error)

GetNode method returns the node which matches to the gived name

func (*Graph) HasCycles

func (g *Graph) HasCycles() bool

HasCycles returns whether a cyclic dependency exists on the whole graph. It calls hasCyclesRec by each root node

type Node

type Node struct {
	Name     string
	Item     interface{}
	Parents  []*Node
	Children []*Node
}

Node is the extended tree graph node

func (*Node) AddChild

func (n *Node) AddChild(child *Node) error

AddChild method update node's childs list adding a new one

func (*Node) AddParent

func (n *Node) AddParent(parent *Node) error

AddParent method update node's parents list adding a new one. It also update parent's childs list

func (*Node) HasChild

func (n *Node) HasChild(child *Node) bool

HasChild method validate whether a child node already exists in node's child list. Two nodes are equal when they have the same node name

func (*Node) HasParent

func (n *Node) HasParent(parent *Node) bool

HasParent method validate whether a parent node already exists in node's parent list. Two nodes are equal when they have the same node name

Jump to

Keyboard shortcuts

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