From 1de3fdeee4f743b00618ad418be917161a772346 Mon Sep 17 00:00:00 2001 From: Alexis Montoison Date: Wed, 25 Sep 2024 12:38:51 -0500 Subject: [PATCH] Add unit tests for transpose_graph --- test/graph.jl | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/graph.jl b/test/graph.jl index 8e4690c..a4543ab 100644 --- a/test/graph.jl +++ b/test/graph.jl @@ -1,6 +1,7 @@ using LinearAlgebra using SparseArrays -using SparseMatrixColorings: Graph, adjacency_graph, bipartite_graph, degree, neighbors +using SparseMatrixColorings: + Graph, adjacency_graph, bipartite_graph, transpose_graph, degree, neighbors using Test ## Standard graph @@ -104,3 +105,20 @@ end; @test collect(neighbors(g, 7)) == [1, 2, 4, 5, 6, 8] @test collect(neighbors(g, 8)) == [1, 2, 3, 5, 6, 7] end + +@testset "transpose_graph" begin + m = 100 + n = 50 + p = 0.02 + A = sprand(m, n, p) + g = transpose_graph(A) + B = sparse(transpose(A)) + @test B.colptr == g.colptr + @test B.rowval == g.rowval + + A = sprand(n, m, p) + g = transpose_graph(A) + B = sparse(transpose(A)) + @test B.colptr == g.colptr + @test B.rowval == g.rowval +end