1
1
"""
2
- color_graph(g::LightGraphs .AbstractGraphs, ::AcyclicColoring)
2
+ color_graph(g::Graphs .AbstractGraphs, ::AcyclicColoring)
3
3
4
4
Returns a coloring vector following the acyclic coloring rules (1) the coloring
5
5
corresponds to a distance-1 coloring, and (2) vertices in every cycle of the
@@ -9,7 +9,7 @@ is a collection of trees—and hence is acyclic.
9
9
10
10
Reference: Gebremedhin AH, Manne F, Pothen A. **New Acyclic and Star Coloring Algorithms with Application to Computing Hessians**
11
11
"""
12
- function color_graph (g:: LightGraphs .AbstractGraph , :: AcyclicColoring )
12
+ function color_graph (g:: Graphs .AbstractGraph , :: AcyclicColoring )
13
13
color = zeros (Int, nv (g))
14
14
two_colored_forest = DisjointSets {Int} (())
15
15
67
67
v::Integer,
68
68
w::Integer,
69
69
x::Integer,
70
- g::LightGraphs .AbstractGraph,
70
+ g::Graphs .AbstractGraph,
71
71
two_colored_forest::DisjointSets{<:Integer},
72
72
color::AbstractVector{<:Integer})
73
73
@@ -81,7 +81,7 @@ function prevent_cycle!(first_visit_to_tree::AbstractVector{<:Tuple{Integer,Inte
81
81
v:: Integer ,
82
82
w:: Integer ,
83
83
x:: Integer ,
84
- g:: LightGraphs .AbstractGraph ,
84
+ g:: Graphs .AbstractGraph ,
85
85
two_colored_forest:: DisjointSets{<:Integer} ,
86
86
color:: AbstractVector{<:Integer} )
87
87
e = find (w, x, g, two_colored_forest)
100
100
first_neighbor::AbstractVector{<: Tuple{Integer,Integer}},
101
101
v::Integer,
102
102
w::Integer,
103
- g::LightGraphs .AbstractGraph,
103
+ g::Graphs .AbstractGraph,
104
104
color::AbstractVector{<:Integer})
105
105
106
106
Grow a 2-colored star after assigning a new color to the
@@ -112,7 +112,7 @@ function grow_star!(two_colored_forest::DisjointSets{<:Integer},
112
112
first_neighbor:: AbstractVector{<: Tuple{Integer,Integer}} ,
113
113
v:: Integer ,
114
114
w:: Integer ,
115
- g:: LightGraphs .AbstractGraph ,
115
+ g:: Graphs .AbstractGraph ,
116
116
color:: AbstractVector{<:Integer} )
117
117
insert_new_tree! (two_colored_forest,v,w,g)
118
118
p, q = first_neighbor[color[w]]
132
132
v::Integer,
133
133
w::Integer,
134
134
x::Integer,
135
- g::LightGraphs .AbstractGraph)
135
+ g::Graphs .AbstractGraph)
136
136
137
137
Subroutine to merge trees present in the disjoint set which have a
138
138
common edge.
@@ -141,7 +141,7 @@ function merge_trees!(two_colored_forest::DisjointSets{<:Integer},
141
141
v:: Integer ,
142
142
w:: Integer ,
143
143
x:: Integer ,
144
- g:: LightGraphs .AbstractGraph )
144
+ g:: Graphs .AbstractGraph )
145
145
e1 = find (v,w,g,two_colored_forest)
146
146
e2 = find (w,x,g,two_colored_forest)
147
147
if e1 != e2
@@ -154,15 +154,15 @@ end
154
154
insert_new_tree!(two_colored_forest::DisjointSets{<:Integer},
155
155
v::Integer,
156
156
w::Integer,
157
- g::LightGraphs .AbstractGraph)
157
+ g::Graphs .AbstractGraph)
158
158
159
159
creates a new singleton set in the disjoint set 'two_colored_forest' consisting
160
160
of the edge connecting v and w in the graph g
161
161
"""
162
162
function insert_new_tree! (two_colored_forest:: DisjointSets{<:Integer} ,
163
163
v:: Integer ,
164
164
w:: Integer ,
165
- g:: LightGraphs .AbstractGraph )
165
+ g:: Graphs .AbstractGraph )
166
166
edge_index = find_edge_index (v,w,g)
167
167
push! (two_colored_forest,edge_index)
168
168
end
@@ -181,28 +181,28 @@ end
181
181
"""
182
182
find(w::Integer,
183
183
x::Integer,
184
- g::LightGraphs .AbstractGraph,
184
+ g::Graphs .AbstractGraph,
185
185
two_colored_forest::DisjointSets{<:Integer})
186
186
187
187
Returns the root of the disjoint set to which the edge connecting vertices w and x
188
188
in the graph g belongs to
189
189
"""
190
190
function find (w:: Integer ,
191
191
x:: Integer ,
192
- g:: LightGraphs .AbstractGraph ,
192
+ g:: Graphs .AbstractGraph ,
193
193
two_colored_forest:: DisjointSets{<:Integer} )
194
194
edge_index = find_edge_index (w, x, g)
195
195
return find_root! (two_colored_forest, edge_index)
196
196
end
197
197
198
198
199
199
"""
200
- find_edge(g::LightGraphs .AbstractGraph, v::Integer, w::Integer)
200
+ find_edge(g::Graphs .AbstractGraph, v::Integer, w::Integer)
201
201
202
202
Returns an integer equivalent to the index of the edge connecting the vertices
203
203
v and w in the graph g
204
204
"""
205
- function find_edge_index (v:: Integer , w:: Integer , g:: LightGraphs .AbstractGraph )
205
+ function find_edge_index (v:: Integer , w:: Integer , g:: Graphs .AbstractGraph )
206
206
pos = 1
207
207
for i in edges (g)
208
208
0 commit comments