Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit 495916b

Browse files
committed
added dispatch for color graph
1 parent 0d8904f commit 495916b

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/coloring/greedy_star1_coloring.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
2222
Reference: Gebremedhin AH, Manne F, Pothen A. **What color is your Jacobian? Graph coloring for computing derivatives.** SIAM review. 2005;47(4):629-705.
2323
"""
24-
function greedy_star1_coloring(g::LightGraphs.AbstractGraph)
24+
function color_graph(g::LightGraphs.AbstractGraph, ::GreedyStar1Color)
2525
v = nv(g)
2626
color = zeros(Int64, v)
2727

src/coloring/greedy_star2_coloring.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
TODO: add text explaining the difference between star1 and
2525
star2
2626
"""
27-
function greedy_star2_coloring(g::LightGraphs.AbstractGraph)
27+
function color_graph(g::LightGraphs.AbstractGraph, :: GreedyStar2Color)
2828
v = nv(g)
2929
color = zeros(Int64, v)
3030

src/coloring/high_level.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ abstract type ColoringAlgorithm end
22
struct GreedyD1Color <: ColoringAlgorithm end
33
struct BSCColor <: ColoringAlgorithm end
44
struct ContractionColor <: ColoringAlgorithm end
5+
struct GreedyStar1Color <: ColoringAlgorithm end
6+
struct GreedyStar2Color <: ColoringAlgorithm end
57

68
"""
79
matrix_colors(A,alg::ColoringAlgorithm = GreedyD1Color())

test/test_greedy_star.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ colors.
3737
for i in 1:5
3838
g = test_graphs[i]
3939

40-
out_colors1 = SparseDiffTools.greedy_star1_coloring(g)
41-
out_colors2 = SparseDiffTools.greedy_star2_coloring(g)
40+
out_colors1 = SparseDiffTools.color_graph(g,SparseDiffTools.GreedyStar1Color())
41+
out_colors2 = SparseDiffTools.color_graph(g,SparseDiffTools.GreedyStar2Color())
4242

4343
#test condition 1
4444
for v = vertices(g)

0 commit comments

Comments
 (0)