You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_merge_trees!(v, w, x, disjoint_sets) # merge trees T₁ ∋ vw and T₂ ∋ wx if T₁ != T₂
323
+
_merge_trees!(v, w, x, forest) # merge trees T₁ ∋ vw and T₂ ∋ wx if T₁ != T₂
324
324
end
325
325
end
326
326
end
327
327
end
328
-
return color, TreeSet(disjoint_sets, parent)
328
+
return color, TreeSet(forest)
329
329
end
330
330
331
331
function_prevent_cycle!(
@@ -337,11 +337,11 @@ function _prevent_cycle!(
337
337
# modified
338
338
first_visit_to_tree::AbstractVector{<:Tuple},
339
339
forbidden_colors::AbstractVector{<:Integer},
340
-
disjoint_sets::DisjointSets{<:Tuple{Int,Int}},
340
+
forest::DisjointSets{<:Tuple{Int,Int}},
341
341
)
342
342
wx =_sort(w, x)
343
-
root =find_root!(disjoint_sets, wx) # edge wx belongs to the 2-colored tree T represented by edge "root"
344
-
id =disjoint_sets.intmap[root] # ID of the representative edge "root" of a two-colored tree.
343
+
root =find_root!(forest, wx) # edge wx belongs to the 2-colored tree represented by edge "root"
344
+
id =forest.intmap[root] # ID of the representative edge "root" of a two-colored tree.
345
345
(p, q) = first_visit_to_tree[id]
346
346
if p != v # T is being visited from vertex v for the first time
347
347
vw =_sort(v, w)
@@ -359,21 +359,19 @@ function _grow_star!(
359
359
color::AbstractVector{<:Integer},
360
360
# modified
361
361
first_neighbor::AbstractVector{<:Tuple},
362
-
disjoint_sets::DisjointSets{Tuple{Int,Int}},
363
-
parent::Vector{Int},
362
+
forest::DisjointSets{Tuple{Int,Int}},
364
363
)
365
364
vw =_sort(v, w)
366
-
push!(disjoint_sets, vw) # Create a new tree T_{vw} consisting only of edge vw
367
-
push!(parent, v) # the vertex v is the parent of the vertex w in tree T_{vw} -- parent[disjoint_sets.intmap[vw]] == v
365
+
push!(forest, vw) # Create a new tree T_{vw} consisting only of edge vw
368
366
(p, q) = first_neighbor[color[w]]
369
367
if p != v # a neighbor of v with color[w] encountered for the first time
370
368
first_neighbor[color[w]] = (v, w)
371
369
else# merge T_{vw} with a two-colored star being grown around v
372
370
vw =_sort(v, w)
373
371
pq =_sort(p, q)
374
-
root1 =find_root!(disjoint_sets, vw)
375
-
root2 =find_root!(disjoint_sets, pq)
376
-
root_union!(disjoint_sets, root1, root2)
372
+
root1 =find_root!(forest, vw)
373
+
root2 =find_root!(forest, pq)
374
+
root_union!(forest, root1, root2)
377
375
end
378
376
returnnothing
379
377
end
@@ -384,34 +382,28 @@ function _merge_trees!(
384
382
w::Integer,
385
383
x::Integer,
386
384
# modified
387
-
disjoint_sets::DisjointSets{Tuple{Int,Int}},
385
+
forest::DisjointSets{Tuple{Int,Int}},
388
386
)
389
387
vw =_sort(v, w)
390
388
wx =_sort(w, x)
391
-
root1 =find_root!(disjoint_sets, vw)
392
-
root2 =find_root!(disjoint_sets, wx)
389
+
root1 =find_root!(forest, vw)
390
+
root2 =find_root!(forest, wx)
393
391
if root1 != root2
394
-
root_union!(disjoint_sets, root1, root2)
392
+
root_union!(forest, root1, root2)
395
393
end
396
394
returnnothing
397
395
end
398
396
399
397
"""
400
398
TreeSet
401
399
402
-
Encode a set of 2-colored trees resulting from the acyclic coloring algorithm.
400
+
Encode a set of 2-colored trees resulting from the [`acyclic_coloring`](@ref) algorithm.
403
401
404
402
# Fields
405
403
406
404
$TYPEDFIELDS
407
-
408
-
# References
409
-
410
-
> [_New Acyclic and Star Coloring Algorithms with Application to Computing Hessians_](https://epubs.siam.org/doi/abs/10.1137/050639879), Gebremedhin et al. (2007), Algorithm 4.1
0 commit comments