graph/product: fix subtle interaction between dst and inputs

The optimisation that is applied for undirected graphs is only valid if
the destination graph is also undirected. So we need to check that and only
apply the optimisation when all three graphs are undirected.
This commit is contained in:
Dan Kortschak
2019-10-29 14:58:18 +10:30
parent b76c2d70ce
commit bfd8b33ce7

View File

@@ -270,7 +270,8 @@ func Modular(dst graph.Builder, a, b graph.Graph) {
_, aUndirected := a.(graph.Undirected)
_, bUndirected := b.(graph.Undirected)
undirected := aUndirected && bUndirected
_, dstUndirected := dst.(graph.Undirected)
undirected := aUndirected && bUndirected && dstUndirected
n := len(product)
if undirected {