This repository was archived by the owner on Aug 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +29
-13
lines changed Expand file tree Collapse file tree 3 files changed +29
-13
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ import Core: SSAValue
13
13
14
14
export contract_color,
15
15
greedy_d1,
16
+ greedy_star1_coloring,
17
+ greedy_star2_coloring,
16
18
matrix2graph,
17
19
matrix_colors,
18
20
forwarddiff_color_jacobian!,
@@ -33,6 +35,8 @@ export contract_color,
33
35
include (" coloring/high_level.jl" )
34
36
include (" coloring/contraction_coloring.jl" )
35
37
include (" coloring/greedy_d1_coloring.jl" )
38
+ include (" coloring/greedy_star1_coloring.jl" )
39
+ include (" coloring/greedy_star2_coloring.jl" )
36
40
include (" coloring/matrix2graph.jl" )
37
41
include (" differentiation/compute_jacobian_ad.jl" )
38
42
include (" differentiation/jaches_products.jl" )
Original file line number Diff line number Diff line change 24
24
TODO: add text explaining the difference between star1 and
25
25
star2
26
26
"""
27
- function greedy_star2_coloring (G :: LightGraphs.AbstractGraph )
27
+ function greedy_star2_coloring (g :: LightGraphs.AbstractGraph )
28
28
v = nv (g)
29
29
color = zeros (Int64, v)
30
30
@@ -55,11 +55,3 @@ function greedy_star2_coloring(G::LightGraphs.AbstractGraph)
55
55
56
56
color
57
57
end
58
-
59
- function find_min_color (forbiddenColors:: AbstractVector , vertex_i:: Integer )
60
- c = 1
61
- while (forbiddenColors[c] == vertex_i)
62
- c+= 1
63
- end
64
- c
65
- end
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ using Random
5
5
Random. seed! (123 )
6
6
7
7
#= Test data =#
8
- test_graphs = Array {VSafeGraph , 1} (undef, 0 )
8
+ test_graphs = Array {SimpleGraph , 1} (undef, 0 )
9
9
10
10
for _ in 1 : 5
11
11
nv = rand (5 : 20 )
@@ -44,19 +44,39 @@ for i in 1:5
44
44
for v = vertices (g)
45
45
color = out_colors1[v]
46
46
for j in inneighbors (g, v)
47
- @test out_color [j] != color
47
+ @test out_colors1 [j] != color
48
48
end
49
49
end
50
50
51
51
# test condition 2
52
52
for j = vertices (g)
53
53
walk = saw (g, j, 4 )
54
54
walk_colors = zeros (Int64, 0 )
55
- if length (saw ) >= 4
55
+ if length (walk ) >= 4
56
56
for t in walk
57
57
push! (walk_colors, out_colors1[t])
58
58
end
59
- @test unique (walk_colors) >= 3
59
+ @test length (unique (walk_colors)) >= 3
60
+ end
61
+ end
62
+
63
+ # test condition 1
64
+ for v = vertices (g)
65
+ color = out_colors2[v]
66
+ for j in inneighbors (g, v)
67
+ @test out_colors2[j] != color
68
+ end
69
+ end
70
+
71
+ # test condition 2
72
+ for j = vertices (g)
73
+ walk = saw (g, j, 4 )
74
+ walk_colors = zeros (Int64, 0 )
75
+ if length (walk) >= 4
76
+ for t in walk
77
+ push! (walk_colors, out_colors2[t])
78
+ end
79
+ @test length (unique (walk_colors)) >= 3
60
80
end
61
81
end
62
82
You can’t perform that action at this time.
0 commit comments