@@ -286,99 +286,3 @@ function decompress_aux!(
286286 end
287287 return A
288288end
289-
290- #=
291- function decompress_aux!(
292- A::AbstractMatrix{R},
293- B::AbstractMatrix{R},
294- result::AbstractColoringResult{:symmetric,:column,:substitution},
295- ) where {R<:Real}
296- @compat (; disjoint_sets, parent) = result
297-
298- # to be optimized!
299- set_roots = Set{Int}()
300- ntrees = 0
301- for edge in tree_set.disjoint_sets.revmap
302- # ensure that all paths are compressed
303- root_edge = find_root!(disjoint_sets, edge)
304- root_index = tree_set.disjoint_sets.intmap[root_edge]
305-
306- # we exclude trees related to diagonal coefficients
307- if (edge[1] != edge[2])
308- push!(set_roots, root_index)
309- end
310- end
311- roots = disjoint_sets.internal.parents
312-
313- # DEBUG
314- println(set_roots)
315- ntrees = length(set_roots)
316- println(ntrees)
317-
318- trees = [Int[] for i in 1:ntrees]
319- k = 0
320- for root in set_roots
321- k += 1
322- for (pos, val) in enumerate(roots)
323- if root == val
324- push!(trees[k], pos)
325- end
326- end
327- end
328- # for k in 1:ntrees
329- # nedges = length(trees[k])
330- # if nedges > 1
331- # tree_edges = trees[k]
332- # p = ...
333- # trees[k] = tree_edges[p]
334- # end
335- # end
336-
337- # DEBUG
338- display(trees)
339-
340- n = checksquare(A)
341- stored_values = Vector{R}(undef, n)
342- if !same_sparsity_pattern(A, S)
343- throw(DimensionMismatch("`A` and `S` must have the same sparsity pattern."))
344- end
345- A .= zero(R)
346- for i in axes(A, 1)
347- if !iszero(S[i, i])
348- A[i, i] = B[i, color[i]]
349- end
350- end
351- for tree in trees
352- nedges = length(tree)
353- if nedges == 1
354- edge_index = tree[1]
355- i, j = disjoint_sets.revmap[edge_index]
356- val = B[i, color[j]]
357- A[i, j] = val
358- A[j, i] = val
359- else
360- for edge_index in tree
361- i, j = disjoint_sets.revmap[edge_index]
362- stored_values[i] = zero(R)
363- stored_values[j] = zero(R)
364- end
365- for edge_index in tree # edges are sorted by their distance to the root
366- i, j = disjoint_sets.revmap[edge_index]
367- parent_index = disjoint_sets.internal.parents[edge_index]
368- k, l = disjoint_sets.revmap[parent_index]
369- # k = parent[edge_index]
370- if edge_index != parent_index
371- if i == k || i == l # vertex i is the parent of vertex j
372- i, j = j, i # ensure that i always denotes a leaf vertex
373- end
374- end
375- val = B[i, color[j]] - stored_values[i]
376- stored_values[j] = stored_values[j] + val
377- A[i, j] = val
378- A[j, i] = val
379- end
380- end
381- end
382- return A
383- end
384- =#
0 commit comments