Research Article

A New Metaheuristic-Based Hierarchical Clustering Algorithm for Software Modularization

Algorithm 2

Pseudocode of convert Prufer sequence to correspond tree (decoding process).
Input: a Prufer sequence as P
Output: a labeled tree
degrees ← a list with size P.size + 2 filled by 1
for i ∈ P do
 degrees[i] ← degrees[i] + 1
end for
# Now we know that node i has degree degrees[i] in the tree
i ← 1
T ← an empty list for tree edges
while at least three items in degrees are nonzero do
 ← first smallest item in degrees
 degrees[i] ← degrees[i] − 1
 Add (ai, ) to T
i ← i + 1
end while
a, b ← nonzero items in degrees
Add (a, b) to T
return T
 return PruferSequence