From 73f82c8a3028ba8e82ed18d985c4d0132ee67b29 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Wed, 15 Apr 2020 08:45:41 -0400 Subject: [PATCH] engine: Small typo/cleanups in autogrouping code --- engine/autogroup.go | 2 +- engine/graph/autogroup/autogroup.go | 2 +- engine/graph/autogroup/base.go | 15 ++++++++++++++- engine/graph/autogroup/util.go | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/engine/autogroup.go b/engine/autogroup.go index b497625dca..1be7d1d163 100644 --- a/engine/autogroup.go +++ b/engine/autogroup.go @@ -39,7 +39,7 @@ type GroupableRes interface { SetAutoGroupMeta(*AutoGroupMeta) // GroupCmp compares two resources and decides if they're suitable for - //grouping. This usually needs to be unique to your resource. + // grouping. This usually needs to be unique to your resource. GroupCmp(res GroupableRes) error // GroupRes groups resource argument (res) into self. diff --git a/engine/graph/autogroup/autogroup.go b/engine/graph/autogroup/autogroup.go index 251de99002..64fd58bff7 100644 --- a/engine/graph/autogroup/autogroup.go +++ b/engine/graph/autogroup/autogroup.go @@ -54,7 +54,7 @@ func AutoGroup(ag engine.AutoGrouper, g *pgraph.Graph, debug bool, logf func(for logf("!VertexMerge for: %s into: %s", wStr, vStr) } else { // success! - logf("success for: %s into: %s", wStr, vStr) + logf("%s into %s", wStr, vStr) merged = true // woo } diff --git a/engine/graph/autogroup/base.go b/engine/graph/autogroup/base.go index 575829fef7..38caaa1940 100644 --- a/engine/graph/autogroup/base.go +++ b/engine/graph/autogroup/base.go @@ -89,6 +89,19 @@ func (ag *baseGrouper) VertexNext() (v1, v2 pgraph.Vertex, err error) { ag.done = true } } + // TODO: is this index swap better or even valid? + //if ag.i < l { + // ag.i++ + //} + //if ag.i == l { + // ag.i = 0 + // if ag.j < l { + // ag.j++ + // } + // if ag.j == l { + // ag.done = true + // } + //} return } @@ -110,7 +123,7 @@ func (ag *baseGrouper) VertexMerge(v1, v2 pgraph.Vertex) (v pgraph.Vertex, err e return nil, fmt.Errorf("vertexMerge needs to be overridden") } -// EdgeMerge can be overridden, since it just simple returns the first edge. +// EdgeMerge can be overridden, since it just simply returns the first edge. func (ag *baseGrouper) EdgeMerge(e1, e2 pgraph.Edge) pgraph.Edge { return e1 // noop } diff --git a/engine/graph/autogroup/util.go b/engine/graph/autogroup/util.go index b2cb2af73c..a0499ded33 100644 --- a/engine/graph/autogroup/util.go +++ b/engine/graph/autogroup/util.go @@ -27,7 +27,7 @@ import ( // 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 +// 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! 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 { // methodology