graph

package
v2.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InitMethodName is the function fn for the reflection
	InitMethodName = "Init"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EdgeType

type EdgeType string
const (
	InitConnection     EdgeType = "InitConnection"
	CollectsConnection EdgeType = "CollectsConnection"
)

type Graph

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

Graph manages the set of services and their edges type of the VerticesMap: directed

func New

func New() *Graph

New initializes endure Graph According to the topological sorting, graph should be 1. DIRECTED 2. ACYCLIC

func (*Graph) AddEdge

func (g *Graph) AddEdge(edgeType EdgeType, src, dest any)

func (*Graph) AddVertex

func (g *Graph) AddVertex(vertex any, weight uint)

AddVertex adds an vertex to the graph with its ID, value and meta information

func (*Graph) Clean

func (g *Graph) Clean()

func (*Graph) HasVertex

func (g *Graph) HasVertex(plugin any) bool

HasVertex returns true or false if the vertex exists in the vertices map in the graph

func (*Graph) Remove

func (g *Graph) Remove(plugin any) []*Vertex

func (*Graph) TopologicalOrder

func (g *Graph) TopologicalOrder() []*Vertex

func (*Graph) TopologicalSort

func (g *Graph) TopologicalSort()

func (*Graph) VertexById

func (g *Graph) VertexById(plugin any) *Vertex

func (*Graph) Vertices

func (g *Graph) Vertices() []*Vertex

func (*Graph) WriteDotString

func (g *Graph) WriteDotString()

type Vertex

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

Vertex is main vertex representation for the graph since we can have cyclic dependencies when we traverse the VerticesMap, we should mark nodes as visited or not to detect cycle

func (*Vertex) ID

func (v *Vertex) ID() reflect.Type

func (*Vertex) IsActive

func (v *Vertex) IsActive() bool

func (*Vertex) Plugin

func (v *Vertex) Plugin() any

func (*Vertex) Weight

func (v *Vertex) Weight() uint

type VertexHeap

type VertexHeap []*Vertex

func (*VertexHeap) Len

func (h *VertexHeap) Len() int

func (*VertexHeap) Less

func (h *VertexHeap) Less(i, j int) bool

func (*VertexHeap) Pop

func (h *VertexHeap) Pop() interface{}

func (*VertexHeap) Push

func (h *VertexHeap) Push(x interface{})

func (*VertexHeap) Swap

func (h *VertexHeap) Swap(i, j int)

Jump to

Keyboard shortcuts

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