begin
 create root;
 set parent of highest level nodes to root;
 candidates highest level nodes;
foreach node candidates do
  if node belongs to a cluster one level above then
   node.parent cluster;
  else
   set node.parent to the neighbor with shortest
   distance to the root;
  end
  node.dist node.parent.dist + 1;
  foreach neighbor of node except node.parent do
   if neighbor has already been visited then
    hide edge;
   else
    candidates candidates neighbor;
   end
  end
end
end
Algorithm 3: treeTransformation.