autogroup

package
v0.0.0-...-453cd44 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutoGroup

func AutoGroup(ag engine.AutoGrouper, g *pgraph.Graph, debug bool, logf func(format string, v ...interface{})) error

AutoGroup is the mechanical auto group "runner" that runs the interface spec. TODO: this algorithm may not be correct in all cases. replace if needed!

func RHVSort

func RHVSort(vertices []pgraph.Vertex) []pgraph.Vertex

RHVSort returns a deterministically sorted slice of all vertices in the list. The order is sorted by the Kind, taking into account the hierarchy of names separated by colons. Afterwards, it uses String() to avoid the non-determinism in the map type. RHV stands for Reverse Hierarchical Vertex, meaning the hierarchical topology of the vertex (resource) names are used.

func VertexMerge

func VertexMerge(g *pgraph.Graph, v1, v2 pgraph.Vertex, vertexMergeFn func(pgraph.Vertex, pgraph.Vertex) (pgraph.Vertex, error), edgeMergeFn func(pgraph.Edge, pgraph.Edge) pgraph.Edge) error

VertexMerge merges v2 into v1 by reattaching the edges where appropriate, and then by deleting v2 from the graph. Since more than one edge between two vertices is not allowed, duplicate edges are merged as well. An edge merge function can be provided if you'd like to control how you merge the edges!

Types

type NonReachabilityGrouper

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

NonReachabilityGrouper is the most straight-forward algorithm for grouping. TODO: this algorithm may not be correct in all cases. replace if needed!

func (*NonReachabilityGrouper) EdgeMerge

func (ag *NonReachabilityGrouper) EdgeMerge(e1, e2 pgraph.Edge) pgraph.Edge

EdgeMerge can be overridden, since it just simply returns the first edge.

func (*NonReachabilityGrouper) Init

func (ag *NonReachabilityGrouper) Init(g *pgraph.Graph) error

Init is called only once and before using other AutoGrouper interface methods the name method is the only exception: call it any time without side effects!

func (*NonReachabilityGrouper) Name

func (ag *NonReachabilityGrouper) Name() string

Name returns the name for the grouper algorithm.

func (*NonReachabilityGrouper) VertexCmp

func (ag *NonReachabilityGrouper) VertexCmp(v1, v2 pgraph.Vertex) error

VertexCmp can be used in addition to an overridding implementation.

func (*NonReachabilityGrouper) VertexMerge

func (ag *NonReachabilityGrouper) VertexMerge(v1, v2 pgraph.Vertex) (v pgraph.Vertex, err error)

VertexMerge needs to be overridden to add the actual merging functionality.

func (*NonReachabilityGrouper) VertexNext

func (ag *NonReachabilityGrouper) VertexNext() (v1, v2 pgraph.Vertex, err error)

VertexNext iteratively finds vertex pairs with simple graph reachability... This algorithm relies on the observation that if there's a path from a to b, then they *can't* be merged (b/c of the existing dependency) so therefore we merge anything that *doesn't* satisfy this condition or that of the reverse!

func (*NonReachabilityGrouper) VertexTest

func (ag *NonReachabilityGrouper) VertexTest(b bool) (bool, error)

VertexTest processes the results of the grouping for the algorithm to know return an error if something went horribly wrong, and bool false to stop.

type RHVSlice

type RHVSlice []pgraph.Vertex

RHVSlice is a linear list of vertices. It can be sorted by the Kind, taking into account the hierarchy of names separated by colons. Afterwards, it uses String() to avoid the non-determinism in the map type. RHV stands for Reverse Hierarchical Vertex, meaning the hierarchical topology of the vertex (resource) names are used.

func (RHVSlice) Len

func (obj RHVSlice) Len() int

Len returns the length of the slice of vertices.

func (RHVSlice) Less

func (obj RHVSlice) Less(i, j int) bool

Less returns the smaller element in the sort order according to the aforementioned rules. XXX: Add some tests to make sure I didn't get any "reverse" part backwards.

func (RHVSlice) Sort

func (obj RHVSlice) Sort()

Sort is a convenience method.

func (RHVSlice) Swap

func (obj RHVSlice) Swap(i, j int)

Swap swaps two elements in the slice.

Jump to

Keyboard shortcuts

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