@@ -30,16 +30,14 @@ function color_graph(g::Graphs.AbstractGraph, ::AcyclicColoring)
3030 for x in outneighbors (g, w)
3131 if color[x] != 0
3232 if forbidden_colors[color[x]] != v
33- prevent_cycle! (
34- first_visit_to_tree,
35- forbidden_colors,
36- v,
37- w,
38- x,
39- g,
40- two_colored_forest,
41- color,
42- )
33+ prevent_cycle! (first_visit_to_tree,
34+ forbidden_colors,
35+ v,
36+ w,
37+ x,
38+ g,
39+ two_colored_forest,
40+ color)
4341 end
4442 end
4543 end
@@ -69,7 +67,6 @@ function color_graph(g::Graphs.AbstractGraph, ::AcyclicColoring)
6967 return color
7068end
7169
72-
7370"""
7471 prevent_cycle!(first_visit_to_tree::AbstractVector{<:Tuple{Integer,Integer}},
7572 forbidden_colors::AbstractVector{<:Integer},
@@ -85,16 +82,14 @@ which is adjacent to vertices w and x in graph g. Disjoint set is used to store
8582the induced 2-colored subgraphs/trees where the id of set is an integer
8683representing an edge of graph 'g'
8784"""
88- function prevent_cycle! (
89- first_visit_to_tree:: AbstractVector{<:Tuple{Integer,Integer}} ,
90- forbidden_colors:: AbstractVector{<:Integer} ,
91- v:: Integer ,
92- w:: Integer ,
93- x:: Integer ,
94- g:: Graphs.AbstractGraph ,
95- two_colored_forest:: DisjointSets{<:Integer} ,
96- color:: AbstractVector{<:Integer} ,
97- )
85+ function prevent_cycle! (first_visit_to_tree:: AbstractVector{<:Tuple{Integer, Integer}} ,
86+ forbidden_colors:: AbstractVector{<:Integer} ,
87+ v:: Integer ,
88+ w:: Integer ,
89+ x:: Integer ,
90+ g:: Graphs.AbstractGraph ,
91+ two_colored_forest:: DisjointSets{<:Integer} ,
92+ color:: AbstractVector{<:Integer} )
9893 e = find (w, x, g, two_colored_forest)
9994 p, q = first_visit_to_tree[e]
10095
@@ -105,7 +100,6 @@ function prevent_cycle!(
105100 end
106101end
107102
108-
109103"""
110104 grow_star!(two_colored_forest::DisjointSets{<:Integer},
111105 first_neighbor::AbstractVector{<: Tuple{Integer,Integer}},
@@ -119,14 +113,12 @@ previously uncolored vertex v, by comparing it with the adjacent vertex w.
119113Disjoint set is used to store stars in sets, which are identified through key
120114edges present in g.
121115"""
122- function grow_star! (
123- two_colored_forest:: DisjointSets{<:Integer} ,
124- first_neighbor:: AbstractVector{<:Tuple{Integer,Integer}} ,
125- v:: Integer ,
126- w:: Integer ,
127- g:: Graphs.AbstractGraph ,
128- color:: AbstractVector{<:Integer} ,
129- )
116+ function grow_star! (two_colored_forest:: DisjointSets{<:Integer} ,
117+ first_neighbor:: AbstractVector{<:Tuple{Integer, Integer}} ,
118+ v:: Integer ,
119+ w:: Integer ,
120+ g:: Graphs.AbstractGraph ,
121+ color:: AbstractVector{<:Integer} )
130122 insert_new_tree! (two_colored_forest, v, w, g)
131123 p, q = first_neighbor[color[w]]
132124
@@ -139,7 +131,6 @@ function grow_star!(
139131 end
140132end
141133
142-
143134"""
144135 merge_trees!(two_colored_forest::DisjointSets{<:Integer},
145136 v::Integer,
@@ -150,21 +141,18 @@ end
150141Subroutine to merge trees present in the disjoint set which have a
151142common edge.
152143"""
153- function merge_trees! (
154- two_colored_forest:: DisjointSets{<:Integer} ,
155- v:: Integer ,
156- w:: Integer ,
157- x:: Integer ,
158- g:: Graphs.AbstractGraph ,
159- )
144+ function merge_trees! (two_colored_forest:: DisjointSets{<:Integer} ,
145+ v:: Integer ,
146+ w:: Integer ,
147+ x:: Integer ,
148+ g:: Graphs.AbstractGraph )
160149 e1 = find (v, w, g, two_colored_forest)
161150 e2 = find (w, x, g, two_colored_forest)
162151 if e1 != e2
163152 union! (two_colored_forest, e1, e2)
164153 end
165154end
166155
167-
168156"""
169157 insert_new_tree!(two_colored_forest::DisjointSets{<:Integer},
170158 v::Integer,
@@ -174,17 +162,14 @@ end
174162creates a new singleton set in the disjoint set 'two_colored_forest' consisting
175163of the edge connecting v and w in the graph g
176164"""
177- function insert_new_tree! (
178- two_colored_forest:: DisjointSets{<:Integer} ,
179- v:: Integer ,
180- w:: Integer ,
181- g:: Graphs.AbstractGraph ,
182- )
165+ function insert_new_tree! (two_colored_forest:: DisjointSets{<:Integer} ,
166+ v:: Integer ,
167+ w:: Integer ,
168+ g:: Graphs.AbstractGraph )
183169 edge_index = find_edge_index (v, w, g)
184170 push! (two_colored_forest, edge_index)
185171end
186172
187-
188173"""
189174 min_index(forbidden_colors::AbstractVector{<:Integer}, v::Integer)
190175
@@ -194,7 +179,6 @@ function min_index(forbidden_colors::AbstractVector{<:Integer}, v::Integer)
194179 return findfirst (! isequal (v), forbidden_colors)
195180end
196181
197-
198182"""
199183 find(w::Integer,
200184 x::Integer,
@@ -204,17 +188,14 @@ end
204188Returns the root of the disjoint set to which the edge connecting vertices w and x
205189in the graph g belongs to
206190"""
207- function find (
208- w:: Integer ,
209- x:: Integer ,
210- g:: Graphs.AbstractGraph ,
211- two_colored_forest:: DisjointSets{<:Integer} ,
212- )
191+ function find (w:: Integer ,
192+ x:: Integer ,
193+ g:: Graphs.AbstractGraph ,
194+ two_colored_forest:: DisjointSets{<:Integer} )
213195 edge_index = find_edge_index (w, x, g)
214196 return find_root! (two_colored_forest, edge_index)
215197end
216198
217-
218199"""
219200 find_edge(g::Graphs.AbstractGraph, v::Integer, w::Integer)
220201
@@ -224,7 +205,6 @@ v and w in the graph g
224205function find_edge_index (v:: Integer , w:: Integer , g:: Graphs.AbstractGraph )
225206 pos = 1
226207 for i in edges (g)
227-
228208 if (src (i) == v && dst (i) == w) || (src (i) == w && dst (i) == v)
229209 return pos
230210 end
0 commit comments