This repository was archived by the owner on Aug 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +65
-1
lines changed Expand file tree Collapse file tree 2 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,10 @@ using Test
4
4
5
5
@testset " Exact coloring via contraction" begin include (" test_contraction.jl" ) end
6
6
@testset " Greedy distance-1 coloring" begin include (" test_greedy_d1.jl" ) end
7
+ @testset " Greedy star coloring" begin include (" test_greedy_star.jl" ) end
7
8
@testset " Matrix to graph conversion" begin include (" test_matrix2graph.jl" ) end
8
9
@testset " AD using color vector" begin include (" test_ad.jl" ) end
9
10
@testset " Integration test" begin include (" test_integration.jl" ) end
10
11
@testset " Special matrices" begin include (" test_specialmatrices.jl" ) end
11
12
@testset " Jac Vecs and Hes Vecs" begin include (" test_jaches_products.jl" ) end
12
- @testset " Jacobian sparsity computation" begin include (" program_sparsity/testall.jl" ) end
13
+ @testset " Jacobian sparsity computation" begin include (" program_sparsity/testall.jl" ) end
Original file line number Diff line number Diff line change
1
+ using SparseDiffTools
2
+ using LightGraphs
3
+ using Random
4
+
5
+ Random. seed! (123 )
6
+
7
+ #= Test data =#
8
+ test_graphs = Array {VSafeGraph, 1} (undef, 0 )
9
+
10
+ for _ in 1 : 5
11
+ nv = rand (5 : 20 )
12
+ ne = rand (1 : 100 )
13
+ graph = SimpleGraph (nv)
14
+ for e in 1 : ne
15
+ v1 = rand (1 : nv)
16
+ v2 = rand (1 : nv)
17
+ while v1 == v2
18
+ v2 = rand (1 : nv)
19
+ end
20
+ add_edge! (graph, v1, v2)
21
+ end
22
+ push! (test_graphs, copy (graph))
23
+ end
24
+
25
+ #=
26
+ Coloring needs to satisfy two conditions:
27
+
28
+ 1. every pair of adjacent vertices receives distinct colors
29
+ (a distance-1 coloring)
30
+
31
+ 2. For any vertex v, any color that leads to a two-colored path
32
+ involving v and three other vertices is impermissible for v.
33
+ In other words, every path on four vertices uses at least three
34
+ colors.
35
+ =#
36
+
37
+ for i in 1 : 5
38
+ g = test_graphs[i]
39
+
40
+ out_colors1 = SparseDiffTools. greedy_star1_coloring (g)
41
+ out_colors2 = SparseDiffTools. greedy_star2_coloring (g)
42
+
43
+ # test condition 1
44
+ for v = vertices (g)
45
+ color = out_colors1[v]
46
+ for j in inneighbors (g, v)
47
+ @test out_color[j] != color
48
+ end
49
+ end
50
+
51
+ # test condition 2
52
+ for j = vertices (g)
53
+ walk = saw (g, j, 4 )
54
+ walk_colors = zeros (Int64, 0 )
55
+ if length (saw) >= 4
56
+ for t in walk
57
+ push! (walk_colors, out_colors1[t])
58
+ end
59
+ @test unique (walk_colors) >= 3
60
+ end
61
+ end
62
+
63
+ end
You can’t perform that action at this time.
0 commit comments