Skip to content

Commit

Permalink
Add unit tests for transpose_graph
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Sep 25, 2024
1 parent 9d890be commit 1de3fde
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/graph.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit 1de3fde

Please sign in to comment.