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

Commit c32a1a4

Browse files
committed
modified distance-1 coloring
1 parent 5c3c702 commit c32a1a4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/coloring/greedy_d1_coloring.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
"""
2-
GreedyD1 Coloring
2+
greedy_d1_coloring
33
44
Find a coloring of a given input graph such that
55
no two vertices connected by an edge have the same
66
color using greedy approach. The number of colors
77
used may be equal or greater than the chromatic
88
number χ(G) of the graph.
99
"""
10-
function color_graph(G::VSafeGraph, alg::GreedyD1Color)
11-
V = nv(G)
12-
result = zeros(Int64, V)
10+
function color_graph(g::VSafeGraph, alg::GreedyD1Color)
11+
v = nv(g)
12+
result = zeros(Int64, v)
1313
result[1] = 1
14-
available = zeros(Int64, V)
15-
for i = 2:V
16-
for j in inneighbors(G, i)
14+
available = BitArray{1}(undef, v)
15+
for i = 2:v
16+
for j in inneighbors(g, i)
1717
if result[j] != 0
18-
available[result[j]] = 1
18+
available[result[j]] = true
1919
end
2020
end
21-
for cr = 1:V
22-
if available[cr] == 0
21+
for cr = 1:v
22+
if available[cr] == false
2323
result[i] = cr
2424
break
2525
end
2626
end
27-
available = zeros(Int64, V)
27+
fill!(available, false)
2828
end
2929
return result
3030
end

0 commit comments

Comments
 (0)