Skip to content

Commit

Permalink
engine: Small typo/cleanups in autogrouping code
Browse files Browse the repository at this point in the history
  • Loading branch information
purpleidea committed May 4, 2021
1 parent 58998f9 commit 4d18741
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion engine/autogroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion engine/graph/autogroup/autogroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
15 changes: 14 additions & 1 deletion engine/graph/autogroup/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion engine/graph/autogroup/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d18741

Please sign in to comment.