Reorganization algorithms initially collect all children to be organized in an array. Then, depending on the organization style a G-Node structure is created accordingly. For horizontal and vertical reorganization a single G-Node is created, and all children are inserted into this node via intermediary G-Nodes, if necessary, when types do not match. In the tiled reorganization algorithm a two-level G-Node tree structure is created to arrange children nodes in the tiled style.

Let's examine the `CollectAllChildren` algorithm first. Basically,
the algorithm recursively collects all the non-G-Node children that
are connected to the window to be reorganized through a sequence of
G-Nodes. As a side-effect the algorithm deletes intermediary G-Nodes.
The index in the array is advanced with each insert operation, and the
number of children in the array is incremented.

Since the horizontal and vertical organization algorithms are simpler
than the tiled organization algorithm lets examine only the `
OrganizeTiled` function.

The `OrganizeTiled` algorithm first collects all children into an
array by calling the `CollectAllChildren` function. Then, the
number of horizontal and vertical partitionings are calculated using
the floor and ceiling of the square root of the number of children
(*n*) to be reorganized. The aim is to create a tiling similar to a
grid as close as possible. For that purpose, *n* is compared to
. If n is greater than
, than the first
partitioning has children, otherwise . In the second level the children are divided as
evenly as possible. Having determined the number children at each
partitioning, a two-level G-Node tree structure is created. All
children are then inserted into this structure in order, through an
extra intermediary G-Node if types do not match. The root of the
G-Node structure then becomes the only child of the window on which a
reorganize operation is applied. Finally effects of the operation is
propagated to lower level windows. The pseudo-code algorithms of (`
CollectAllChildren`) and (`OrganizeTiled`) functions are listed in
Appendix .

Sun Sep 13 18:34:46 EDT 1998