Skip to content

Commit eabd72f

Browse files
committed
wip
1 parent 53b2709 commit eabd72f

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/coloring.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ function TreeSet(
389389
S = pattern(g)
390390
edge_to_index = edge_indices(g)
391391
nv = nb_vertices(g)
392-
nt = forest.num_trees
392+
nt = forest.nt
393393

394394
# root_to_tree is a vector that maps a tree's root to the index of the tree
395395
# We can recycle forest.ranks because we don't need it anymore to merge trees
@@ -421,8 +421,8 @@ function TreeSet(
421421

422422
found_in_tree = Vector{Bool}(undef, nt)
423423
colptr_tree = zeros(T, ne + nt + 1)
424-
vertices1 = Vector{T}(undef, ne + nt)
425-
vertices2 = Vector{T}(undef, 2 * ne)
424+
vertices_trees = Vector{T}(undef, ne + nt)
425+
neighbors_trees = Vector{T}(undef, 2 * ne)
426426

427427
pos_vertices1 = Vector{T}(undef, nt)
428428
pos_vertices2 = Vector{T}(undef, nt)
@@ -453,15 +453,15 @@ function TreeSet(
453453
pos_vertices1[index_tree] += 1
454454
# add j in the list of vertices of the current tree
455455
p = pos_vertices1[index_tree]
456-
vertices1[p] = j
456+
vertices_trees[p] = j
457457
end
458458
# increase the number of neighbors for j in the current tree
459459
p = pos_vertices1[index_tree]
460460
colptr_tree[p] += 1
461461
# increase the position of the visited neighbors in the current tree
462462
pos_vertices2[index_tree] += 1
463463
q = pos_vertices2[index_tree]
464-
vertices2[q] = i
464+
neighbors_trees[q] = i
465465
end
466466
end
467467
end
@@ -515,7 +515,7 @@ function TreeSet(
515515

516516
# compute the degree of each vertex in the tree
517517
for pos1 in first:last
518-
vertex = vertices1[pos1]
518+
vertex = vertices_trees[pos1]
519519
degree = colptr_tree[pos1 + 1] - colptr_tree[pos1]
520520
degrees[vertex] = degree
521521

@@ -539,7 +539,7 @@ function TreeSet(
539539

540540
mleaf = mapping[leaf]
541541
for pos2 in colptr_tree[mleaf]:(colptr_tree[mleaf + 1] - 1)
542-
neighbor = vertices2[pos2]
542+
neighbor = neighbors_trees[pos2]
543543

544544
# Check if neighbor is the parent of the leaf or if it was a child before the tree was pruned
545545
if degrees[neighbor] != 0

src/forest.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ $TYPEDFIELDS
1111
"""
1212
mutable struct Forest{T<:Integer}
1313
"current number of distinct trees in the forest"
14-
num_trees::T
14+
nt::T
1515
"vector storing the index of a parent in the tree for each edge, used in union-find operations"
1616
parents::Vector{T}
1717
"vector approximating the depth of each tree to optimize path compression"
1818
ranks::Vector{T}
1919
end
2020

2121
function Forest{T}(n::Integer) where {T<:Integer}
22-
num_trees = T(n)
22+
nt = T(n)
2323
parents = collect(Base.OneTo(T(n)))
2424
ranks = zeros(T, T(n))
25-
return Forest{T}(num_trees, parents, ranks)
25+
return Forest{T}(nt, parents, ranks)
2626
end
2727

2828
function _find_root!(parents::Vector{<:Integer}, index_edge::Integer)
@@ -51,6 +51,6 @@ function root_union!(
5151
rks[index_edge1] += one(T)
5252
end
5353
parents[index_edge2] = index_edge1
54-
forest.num_trees -= one(T)
54+
forest.nt -= one(T)
5555
return nothing
5656
end

0 commit comments

Comments
 (0)