From bfd8b33ce79b6ee36d222a6775f0aa068795ee39 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Tue, 29 Oct 2019 14:58:18 +1030 Subject: [PATCH] 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. --- graph/product/product.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graph/product/product.go b/graph/product/product.go index 9f098c35..354b0025 100644 --- a/graph/product/product.go +++ b/graph/product/product.go @@ -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 {