mirror of
https://github.com/gonum/gonum.git
synced 2025-10-28 17:31:56 +08:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user