From 07c40b031f167974efd7380bc4659757644ff994 Mon Sep 17 00:00:00 2001 From: Marcel Wack Date: Thu, 14 Sep 2023 14:18:35 +0200 Subject: [PATCH 1/4] automorphism_group fix for rank 0 matroids + added test --- src/Combinatorics/Matroids/matroids.jl | 5 ++++- test/Combinatorics/Matroids/Matroids.jl | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Combinatorics/Matroids/matroids.jl b/src/Combinatorics/Matroids/matroids.jl index 5fc0f2cbf7a9..43865ef13df7 100644 --- a/src/Combinatorics/Matroids/matroids.jl +++ b/src/Combinatorics/Matroids/matroids.jl @@ -864,4 +864,7 @@ julia> automorphism_group(M) Group([ (3,4), (1,2), (2,3) ]) ``` """ -automorphism_group(m::Matroid) = automorphism_group(IncidenceMatrix(bases(m));action=:on_cols) +function automorphism_group(m::Matroid) + length(m) > 0 || throw(ArgumentError("The matroid should not be empty.")) + rank(m) < 1 ? automorphism_group(dual_matroid(m)) : automorphism_group(IncidenceMatrix(bases(m));action=:on_cols) +end diff --git a/test/Combinatorics/Matroids/Matroids.jl b/test/Combinatorics/Matroids/Matroids.jl index 242f911da2c8..5311282fd935 100644 --- a/test/Combinatorics/Matroids/Matroids.jl +++ b/test/Combinatorics/Matroids/Matroids.jl @@ -343,5 +343,6 @@ @testset "matroid automorphism" begin M = uniform_matroid(3, 5) @test order(automorphism_group(M)) == 120 + @test automorphism_group(uniform_matroid(0, 2)) == symmetric_group(2) end end From b498655318b7a390bb3c66e5429502668579ac19 Mon Sep 17 00:00:00 2001 From: Marcel Wack <63490664+Sequenzer@users.noreply.github.com> Date: Thu, 14 Sep 2023 15:53:26 +0200 Subject: [PATCH 2/4] Update src/Combinatorics/Matroids/matroids.jl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lars Göttgens --- src/Combinatorics/Matroids/matroids.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Combinatorics/Matroids/matroids.jl b/src/Combinatorics/Matroids/matroids.jl index 43865ef13df7..9896006f7dbc 100644 --- a/src/Combinatorics/Matroids/matroids.jl +++ b/src/Combinatorics/Matroids/matroids.jl @@ -865,6 +865,6 @@ Group([ (3,4), (1,2), (2,3) ]) ``` """ function automorphism_group(m::Matroid) - length(m) > 0 || throw(ArgumentError("The matroid should not be empty.")) + @req length(m) > 0 "The matroid should not be empty." rank(m) < 1 ? automorphism_group(dual_matroid(m)) : automorphism_group(IncidenceMatrix(bases(m));action=:on_cols) end From fe86333c97e0fdb22082545d4a2223d5b929f346 Mon Sep 17 00:00:00 2001 From: Marcel Wack Date: Mon, 18 Sep 2023 11:35:06 +0200 Subject: [PATCH 3/4] fixed loop bug and added test --- src/Combinatorics/Matroids/matroids.jl | 8 +++++++- test/Combinatorics/Matroids/Matroids.jl | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Combinatorics/Matroids/matroids.jl b/src/Combinatorics/Matroids/matroids.jl index 9896006f7dbc..ee48d09026b1 100644 --- a/src/Combinatorics/Matroids/matroids.jl +++ b/src/Combinatorics/Matroids/matroids.jl @@ -866,5 +866,11 @@ Group([ (3,4), (1,2), (2,3) ]) """ function automorphism_group(m::Matroid) @req length(m) > 0 "The matroid should not be empty." - rank(m) < 1 ? automorphism_group(dual_matroid(m)) : automorphism_group(IncidenceMatrix(bases(m));action=:on_cols) + I = rank(m) < 1 ? IncidenceMatrix(bases(dual_matroid(m))) : IncidenceMatrix(bases(m)) + resize!(I, nrows(I), length(m)) + return automorphism_group(I;action=:on_cols) end + + + + diff --git a/test/Combinatorics/Matroids/Matroids.jl b/test/Combinatorics/Matroids/Matroids.jl index 5311282fd935..b53d571425c9 100644 --- a/test/Combinatorics/Matroids/Matroids.jl +++ b/test/Combinatorics/Matroids/Matroids.jl @@ -344,5 +344,7 @@ M = uniform_matroid(3, 5) @test order(automorphism_group(M)) == 120 @test automorphism_group(uniform_matroid(0, 2)) == symmetric_group(2) + U = matroid_from_bases([[1,2],[2,3],[1,3]],5) + @test automorphism_group(U) == automorphism_group(dual_matroid(U)) end end From 058a6dd2041c06da60f3f81ed3008f73fc0ca271 Mon Sep 17 00:00:00 2001 From: Benjamin Lorenz Date: Mon, 18 Sep 2023 12:02:59 +0200 Subject: [PATCH 4/4] Update src/Combinatorics/Matroids/matroids.jl --- src/Combinatorics/Matroids/matroids.jl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Combinatorics/Matroids/matroids.jl b/src/Combinatorics/Matroids/matroids.jl index ee48d09026b1..8be56c69b268 100644 --- a/src/Combinatorics/Matroids/matroids.jl +++ b/src/Combinatorics/Matroids/matroids.jl @@ -868,9 +868,5 @@ function automorphism_group(m::Matroid) @req length(m) > 0 "The matroid should not be empty." I = rank(m) < 1 ? IncidenceMatrix(bases(dual_matroid(m))) : IncidenceMatrix(bases(m)) resize!(I, nrows(I), length(m)) - return automorphism_group(I;action=:on_cols) + return automorphism_group(I; action=:on_cols) end - - - -