graph

package
Version: v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package graph has all the Graph logic that we need to interact with Graph, Node and Edge.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	ID string

	Canonicals []string

	Source string
	Target string
	// contains filtered or unexported fields
}

Edge defines the standard format of an Edge

func (*Edge) AddCanonicals

func (e *Edge) AddCanonicals(cans ...string)

AddCanonicals adds the cans to the internal list, if one is repeated it'll be ignored

func (*Edge) Replace

func (e *Edge) Replace(src, rep string) error

Replace replaces the src (on Target or Source) for rep values

type Graph

type Graph struct {
	Edges []*Edge
	Nodes []*Node
	// contains filtered or unexported fields
}

Graph defines the standard format of a Graph

func New

func New() *Graph

New returns a new initialized Graph

func (*Graph) AddEdge

func (g *Graph) AddEdge(e *Edge) error

AddEdge adds an Edge to the Graph

func (*Graph) AddNode

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

AddNode adds an Node to the Graph

func (*Graph) Clean

func (g *Graph) Clean()

Clean removes all the Nodes that do not have any edge

func (*Graph) GetEdgesForNode

func (g *Graph) GetEdgesForNode(nID string) []*Edge

GetEdgesForNode returns all the edges that have relation to this nID

func (*Graph) GetNodeByCanonical added in v0.4.0

func (g *Graph) GetNodeByCanonical(nCan string) (*Node, error)

GetNodeByCanonical returns the requested Node with the nCan

func (*Graph) GetNodeByID

func (g *Graph) GetNodeByID(nID string) (*Node, error)

GetNodeByID returns the requested Node with the nID

func (*Graph) InvertEdge

func (g *Graph) InvertEdge(eID string)

InvertEdge inverts the Source and Target of the eID

func (*Graph) RemoveNodeByID added in v0.3.0

func (g *Graph) RemoveNodeByID(ID string) error

RemoveNodeByID removes the Node with the ID and the Edges associated with it

func (*Graph) Replace

func (g *Graph) Replace(srcID, repID string) error

Replace will replace the srcID Node for the repID Node by removing the srcID and connecting all the edges from srcID to repID. srcID Node and repID Node have to be connected directly

type Node

type Node struct {
	// ID it'a a random UUID
	ID string

	// Canonical it's 'aws_lb.front' format
	Canonical string

	// Position holds the position of the node if any
	Position []int // x, y

	// TFID it's the internal ID it has on TF
	TFID string

	// Resource it's the information of the resource
	// it holds
	Resource resource.Resource

	// Weight is the addition of the Directions
	// of the Node
	Weight int
}

Node defines the standard format of an Edge

Jump to

Keyboard shortcuts

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