Skip to content

Commit f4016eb

Browse files
committed
fix: msbfs tests
1 parent 7b21b4f commit f4016eb

File tree

1 file changed

+10
-6
lines changed
  • tests/GraphBLAS-sharp.Tests/Backend/Algorithms

1 file changed

+10
-6
lines changed

tests/GraphBLAS-sharp.Tests/Backend/Algorithms/MSBFS.fs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ open GraphBLAS.FSharp.Objects
1111
open GraphBLAS.FSharp.Objects.MatrixExtensions
1212

1313
let config = Utils.undirectedAlgoConfig
14+
1415
let workGroupSize = Utils.defaultWorkGroupSize
1516

1617
let makeLevelsTest context queue bfs (matrix: int [,]) =
@@ -19,11 +20,14 @@ let makeLevelsTest context queue bfs (matrix: int [,]) =
1920
let largestComponent =
2021
ConnectedComponents.largestComponent graph
2122

23+
Array.sortInPlace largestComponent
24+
2225
if largestComponent.Length > 1 then
2326
let sourceVertexCount = max 2 (largestComponent.Length / 10)
2427

2528
let source =
26-
largestComponent.[0..sourceVertexCount]
29+
largestComponent.[0..sourceVertexCount - 1]
30+
|> Array.sort
2731
|> Array.toList
2832

2933
let matrixHost =
@@ -35,7 +39,7 @@ let makeLevelsTest context queue bfs (matrix: int [,]) =
3539
Array2D.zeroCreate sourceVertexCount (Array2D.length1 matrix)
3640

3741
source
38-
|> Seq.iteri
42+
|> List.iteri
3943
(fun i vertex ->
4044
(snd (BFS.runUndirected graph vertex))
4145
|> Utils.createArrayFromDictionary (Array2D.length1 matrix) 0
@@ -53,7 +57,7 @@ let makeLevelsTest context queue bfs (matrix: int [,]) =
5357
| Matrix.COO a, Matrix.COO e -> Utils.compareCOOMatrix (=) a e
5458
| _ -> failwith "Not implemented"
5559

56-
let createLevelsTest context queue testFun =
60+
let createLevelsTest<'a> context queue testFun =
5761
testFun
5862
|> makeLevelsTest context queue
5963
|> testPropertyWithConfig config $"test on %A{typeof<'a>}"
@@ -64,12 +68,12 @@ let levelsTestFixtures (testContext: TestContext) =
6468

6569
let bfsLevels =
6670
Algorithms.MSBFS.runLevels
67-
(fst ArithmeticOperations.intAdd)
68-
(fst ArithmeticOperations.intMul)
71+
ArithmeticOperations.intAddWithoutZero
72+
ArithmeticOperations.intMulWithoutZero
6973
context
7074
workGroupSize
7175

72-
createLevelsTest context queue bfsLevels ]
76+
createLevelsTest<int> context queue bfsLevels ]
7377

7478
let levelsTests =
7579
TestCases.gpuTests "MSBFS Levels tests" levelsTestFixtures

0 commit comments

Comments
 (0)