Documente Academic
Documente Profesional
Documente Cultură
Lukes
e .
Abstract: This paper describes an algorithm for partitioning a graph that is in the form of a tree. The algorithm has a growth in com-
putation time and storage requirements thatis directly proportional to the number of nodes in the tree. Several applications of the algo-
rithm are briefly described. In particular it is shown that the tree partitioning problem frequently arises in the allocation of computer
information to blocks of storage. Also, a heuristic method of partitioning ageneral graph based on this algorithm is suggested.
Introduction
Consider a graph G whose nodes have nonnegative inte- scribed here can arise in the allocation of data in hierar-
ger weightsand whose edges have positivevalues.A chical files to physical blocks of storage. Also, we sug-
familiar combinatorial problem is the partitioning of G gest a possible heuristic procedure based on the algo-
into subgraphs such that the sum of the node weights in rithm for the partitioning of a general graph.
any subgraph does not exceed a given maximum and the
sum of the values of theedges joining the different Definitions and basic concepts
subgraphs is minimal. Thistype of graph partitioning Assume a tree T = ( V , E ) with node set V and edge set
problem arises in a variety of forms in computer sys- E , as shown in Fig. 1. A partition of T is defined as a
tems, e.g., the clustering of logic circuits onto integrated collection of k clusters of nodes {ci), i = 1 , 2 , . . ., k, such
circuit chips and the mapping of computer information that
onto physical blocks of storage. k
No computationally efficient algorithm is known to u ci= v;
i=l
exist for the partitioning of a general graph. However,
partitioning algorithms have been described [ 1-81 that ci n cj = 0 for all i # j .
can be computationally efficient, given special features
Anonnegativeinteger weight wi is associated with
of the graph to bepartitioned.
each node i of T . A weight constraint W is imposed on
Here we restrict our attention to connected, acyclic
each clusterof T such that the sumof the weights of the
graphs, or trees, and describe a dynamic programming
nodes of any cluster does not exceedW .
algorithm for the partitioning of a tree. This partitioning
An edge (i, j ) of T is said to be cut by a partition of T
algorithm has a growth in computation time and storage
if nodes i and j are in different clusters. A positive value
requirementsdirectly proportional tothenumber of
uii is associated with each edge ( i ,j ) of T . The value of a
nodes in the graph. The ability to partition a tree with
partition of T is equal to the sum of the values of the
integer-weighted nodes andmultivaluededges has not
edges of T that are within its clusters (intracluster edges);
been considered in the literature. An algorithm [ 2 ] has
the cost of a partition of T is equal to the sum of the
been reported that partitions a special type of tree with a
values of the edges of T that are cutby the partition of T
growth in computation of n(log, n ) for an n-node tree;
(intercluster edges). Thus the value plus the cost of a
the edges of the tree must, however, assume a rather
partition of T is equal to the sum of the values of the
restricted set of values.
edges of T .
In this paper we first define the partitioning problem,
An optimal partition of T , pT (opt) = {cl, cZ; . c,}, is
e,
MAY 1974
Partition = ( ]
C I ~ C ~ C ~
T= (V,E) c1= [A,B] Partitionp=(1,2,3) (4,6,8) (5,7)
v = (A,B,c,D,E) c2=[C,D) Valueofp=3+2+4+3+8
E = (o,b,c,d) c3 = {El Costofp=6+1
Figure 1 A partition of the tree T = ( V , E ) ,where the weight Figure 2 Value and cost of a partition.
constraint is 2 and all nodes are assumed to have unit weight.
I.
and in which cost rected, ordered treeis defined [ 101 to be a finite set T of
one or more nodes suchthat:
uij is minimal,
where i c f , j c & g = 1,2; . ., k, and f # g. An equivalent 1. There is a distinct node called the root of T,
property of an optimal partition of G is one that satisfies 2. The remaining nodes (exclGding the root) are, sepa-
the weight constraint and in which the value of T rated into m P 0 disjoint sits TI,., TI2,. ., TI,,,, and
each of these setsis in turn a birected, ordered tree.
2 uij is maximal,
i,jccf The trees T , , TI,,. . ., T , are called the subtrees of the
where f = 1, 2 , . . ., k., root, whereT , is the first subtree, T , the secopd, etc.
The particular directed,orderedtree used does npt
To identify the different liodes of a tree, the tree is affect thegrowth incomputationalcomplexity of the
labeled by the assignment of a unique integer to each algorithm. By convention we form T by selecting node
node, as in Fig. 2. To represent a partition we use a 1 as the root of T and the sons of node 1 become those
collection of lists in which each list represents a cluster nodes adjacentto (sharing an edge with)node 1 . The
and the contents of the list are the nodes in that cluster. sons of node 1 are ordered by increasing label value. If
For example,a cluster with nodes 1, 3, 5, and 6 is repre- node i is a son of node 1 , those nodes adjacent to node i
sented by the list ( 1, 3, 5, 6 ) , where the order in which (excluding node 1) are again ordered as the sons of node i
the nodes appear in the list is not important. An example by increasing label values. This process is repeated for
of a representation of a partition with this cluster is each node in T resulting in the ordered, directed treeT .
(1, 3, 5 , 6 ) ( 2 , 4 , ) ( 7 ) .
Each cluster formedby a partition of tree T represents
a subtree of T . However; we restrict, our attention. to Partitioning algorithm
partitions of T each of whose clusters forms a connected The basis of the tree partitioning algorithm is a dynamic
subtree of T , where connected means that every pair of programming technique that takes advantage of a basic
nodes in the subtree is joined by a path [9]. We can ap- property of a tree, its acyclic nature, to find a globally
ply this connectivity constraint [7] because the clus- optimal partition based on local information. The algo-
ters of an optimal partition of any connected graph can rithm generates the optimal partition of the tree T ! by
be modified by forming from each clusterci a set of clus- finding the partitions of increasingly larger subtrees of T
terseach of which consists of a connected subgraph until the subtree that is partitioned is T itself.
contained in ci. Since the original partition was optimal The first step in the partitioning algorithm is to gener-
and the new partition costs no more than the original, ate the trivial partitions of the leaf nodes of T . We then
such a modification results in an optimal partition each determine that set of nodes in T all of whose subtrees
of whose clusters is a connected subgraph. have been partitioned. Assume that there is a node in
For notational convenience, we change the given tree this set with the label x. We generate the partitions of x
218 T into a directed and ordered tree T , as in Fig. 3. A di- by means of the following sequence of steps:
I
I
I j
I
I
I
Subtree V -Subtree U
Figure 3 Transformation of tree into a directed tree. (a) Tree Figure 4 Generation of partitions by combining the partitions
T ; ( b ) directed, ordered tree T. of two subtrees.
1 . Find the partitions of node x and its first subtree. Before this algorithm can be considered to be practi-
2. Combinethese partitions andthe partitions of the cal, however, we must first find some orderly method of
second subtree of x to generate the partitions of, the generating the partitions of a subtree consisting of some
subtree composed of node x and its first two subtrees. +
node u and its first i 1 subtrees, given the partitions of
3. Combine the partitions created in step 2 with the par- the subtree .composed of u and its first i subtrees and the
titions of the third subtree of x. The result is the set partitions of the (i+ 1)st subtree. Next,we observe that
of partitions of the subtree composed of node x and the number of partitions of a subtree can become very
its first three subtrees. large. For example,considerthe simple treestructure
4. Continue this proceduresuchthat on the ( i 1)st + consisting of a node of T all of whose sons are leaf
step the partitions of the subtree composed of node x nodes. The number of partitions of this tree such that
+
and its first i 1 subtrees are generatedby combining the weight and connectivity constraintsare bothob-
the pahitions generated on step i with the partitions served is
+
of the ( i 1 )st subtree of x.
w-1
5. Finally we reach a point in the algorithm when the
tree with root x is partitioned. c (3
1=0
A s a result of the partitioning of the tree with root x, it where k = number of nodes in the tree and W = the
may happen that the node thatis the father of x becomes weight constraint. For w > k / 2 , thisbound grows as
qualified as a node all of whose subtrees are partitioned. 2k. We solve this problem by eliminating a large number
If such is the case, we add the father of node x to this of pahitions of eachsubtree in the partitioning al-
set. gorithm.
Upon finishing the partitioning of the tree with root Consider s.ome subtree of T , U in Fig. 4, which in
node x, .we remove node x from the set of nodes sharing general consistsof a node u and its first i subtrees. In the
thepropertythat all of theirsubtreesare partitioned. proof of optimality to come later we will show that we
Another node from this set is selected, and the tree for need carry only a maximum of W partitions of U along
which this node is the root is partitioned in the manner in the partitioning process, where W is the weight con-
described above. At somepoint in the algorithm, the set straint. If w is the weight of node u, this set of partitions
of nodes each of whose subtreesis partitioned is exhaust- +
is denoted by ui ( i = w ,w 1,. . ., W ), where each parti-
ed, whereupon we have generated the optimal partition tion uiis distinguished from the other partitions of U by
of T . the properties: 21 91
those of a partition of V , uj, merging the nodes in the Step 4 Denote by x0 the partition of the subtree whose
clusters containing nodes u and u into a single cluster. root is x that has maximal value from the set {x,, x,+,,
2 . Concatenate the clusters of ui and uj. . . . ,x,}.
Delete the sonsof node x from the treeT ' . If node x is
We observe that any other combination of the partitions the root of T ' , then x0 represents theoptimal partition of
ui and uj violates the connectivity constraint.
T' (hence of T ) . Otherwise, go to Step 3.
Let us use the notation C [ u i , uj] to denote the parti-
tion created by the first operation above. The weight of
Proof of optimality
+
the cluster of C [ u i ,uj] containing node u is i j, and its Consider some optimal partition q of the tree T'. As-
partition value is the sum of the value of ui, uj, and edge
sume that each clusterof q contains a connected subtree
(i, j ) . The partition created by the second operation can of T ' . As a consequence, we can separate the clustersof
also be denoted by the above notation if we define uo to q into threegroups:
be the partition of V that has the maximal value of all
partitions of V. (If the second operation were used to 1. Those clusters comprised of nodes in thesubtrees
combine ui with any partition uj, the resulting partition whose roots are the first i sons of some nodeu,
could never havea value greater thanC [ui,uo] . Thus, we 2. A single cluster containing node u,
only consider the combination C [ui, UO] in forming some 3. All other clusters.
ui' using the second operation.) Then C [ u i , U O ] repre-
sents a partition of U' whose cluster containing node u Let us now proceedto delete from the clustersof q all
is of weight i and whose value is equal to the sum of the those nodes (except nodeu ) not in a subtree whose root
values of ui and UO. is one of the first i sons of node u. The resulting clusters
We note that the assumption is made that all nodes in comprise a partition li of the subtree U of Fig. 4. We
T (hence in T ' ) are integer-weighted. Therefore,the now claim that if the cluster of I; containing node u is of
partition uK' of U' is selected from the set { C [ u , , u k - , ] , weight j , then the valueof li is equal to that
of uj.
C[u,, u J , . . ., C[u,-,, u,l, c [ u k 7 ~ 0 1 1where
, ~ we as- Let us assume that the value of li is less than that of
sume nodes u and u have unit weight for clarity of nota- uj. We can then generate a partition p whose value ex-
tion. (See Fig. 5.) The partition C [ u a , u,] in thisset ceeds that of q by the amount that uj exceeds I;. We do
with maximal value is selected as uk'. so as follows:
We now summarize the steps associated with the par-
titioning algorithm. 1. Make the clustersof p containing nodes not in subtree
U equal to the clustersof q that are in the third group
Step I Label the tree T , and form the directed, order above.
tree T ' . 2. Add the remaining nodes of T' (i.e., those nodes not
Step 2 For each leaf node u with weight w , form the in a cluster of or in one of the group 3 clusters of q )
partition u, = uo = ( u ) . The value of this partition is to the cluster containing node u. We note that these
zero. For all nodes u of T' that are branch nodes (nodes nodes are precisely thenodes in the single cluster
having one or more sons), initialize ( u ) = uj with value comprising group 2 of q not found in subtree U .
zero; herej is the weight of node u.
Step 3 Select some node x all of whose sons are leaf Clearlythen q cannotbe optimal if li does not have
220 nodes, and form the optimal partitions for each weight equal value touj.
Growth rate
Consider the number of steps required to form all pos-
siblepartitions in combining the subtrees U and V of
Fig. 4 to create the a maximum
partitions of U'. There are
of W partitions uj' representing the set of optimal parti-
tions of U'. Each such partition is chosen from a max-
+
imum o f j partitions C [u,, ub], where a b =j and 1 5 a ,
0 5 b. The maximum number of partitions that must be
considered in forming the uj' is then given by the series
1+2+3...+W=W(W+1)/2 .
In forming the optimal partition of T ' , we are required
to combine thepartitions of some U with the partitions of
some V once for every edgein the tree. Since an n-node
tree hasn - 1 edges, the computationalcomplexity grows
as W'n and is independent of the particular structure of
the tree under consideration.
Example
We now illustrate the algorithm just described by means
of an example. The tree of Fig. 6 (a) is to be partitioned
for a weight constraint of three. Each node is assumed to
have unit weight, and the edges have the values shown. Value = 12
Figure 6 (b) shows the directed and ordered tree T' re- Cost = 3
All edges = 1
Tree partitioning problems
Graphs in the form of trees occur frequently in the rep-
resentation of computer information. Certain linked
lists, segments of nonrecursive programs, and hierarchi-
cal file structuresareseveralexamples of suchtree
structures.Thetree partitioningproblem ariseswhen
informationmust be allocated to blocks of memory
whose capacity is limited. Kernighan [3] noted that the
placement of program segments into pages in memory
hierarchies is such a partitioning problem. Here the tree
nodes are the segments, a node weight equals the num-
ber of bytes in a segment, and the edges represent a
probable transition from one segmentto another and are
assignedvalues equaltotheexpectedtransitions be-
tween segments. The problem is then reduced to one of
(b) allocating nodes to clusters (pages) so as to reduce the
Figure 7 Application of tree partitioning. (a) Logical relation-
expected number of page faults while executing the pro-
ship of data in a hierarchical file; (b) allocation of data to 32- gram.
byte blocks. A similar example of a tree partitioning problem is the
distribution of the data of a hierarchical file structure
into blocks of memory on a secondary storage device.
One is given a logical data structure whose nodes con-
sist of datasegments and directory informationand
whoseedges imply a logical relationship of data seg-
Therefore ments. If the expected transitions from node to node of a
datastructureareknown,thestructureassumesthe
2,= (2, 3, 5 ) V[2,] = 10
form of a tree withweighted nodes and edges whose
2, = (2) ( 3 ) ( 5 ) V[2,1 =0
valuesequaltheexpectedinternode transitions. The
2, = (2, 5 ) ( 3 ) V[2,] =6
objective then is to allocate nodes of the tree to finite
2, = 2, V[2,] = 10.
capacity storage blocks. Since a search operation is re-
To form the partitions of the subtree whose rootis 1, the quired for each block of information in secondary stor-
first iteration is age, it is advantageous to cluster information referenced
togetherfrequentlyintothesame blocks.Distributing
1,' = C[l,, 2,] = ( 1 ) (2, 3, 5 ) * with value = 10.
the nodes in blocks such that the sum of the expected
1,' = [C[l,, 2,] ( 1 , 2)(3, 5 ) *
= with value= 3
C [l,, 2,] does not occur since 1, has not yet oc-
transitionsbetween blocks is minimized results in the
minimum number of interblock transitions for thehierar-
curred. chical file structure. Figure 7 illustrates this problem.
We note that every connected graph has a number of
C[1,, 2,]= ( 2 , 5 , 1 )( 3 ) * with value = 9
i
1,' = C [l,, 2,] does not exist since1, does not yet exist
C [l,, 2,] does not exist since
The second iteration is
1, does not yetexist.
embedded trees within it. For example, Fig. 8 shows a
graph and one of its embedded trees. A heuristic algo-
rithm for the partitioning of a general graph can be for-
mulated baseduponthetree partitioningalgorithm,
where the partitioned tree is an embedded tree of the
1,' = C[l,, 4,] = ( 1 ) (2, 3, 5 ) (4)* with value = 10
givengraph. First, an embedded tree T is determined
222
1,' = [CC[l,, 4,]
[l,, 4,]
= ( 1 , 4) (2, 3, 5 ) *
= ( 1 , 2) (3, 5 ) ( 4 )
with value = 12-
with value = 3
from the given graph G. Those edges of G not in this
tree are then consideredto be cut. The embedded treeis
w
Figure 9 Heuristic graph partitioning. (a) Graph G ; (b)
above technique. embedded tree T (maximal spanning tree); (c) resulting parti-
tion of T ; (d) partition of G .
,Edge value
Summary
We have .described a computationally efficient algorithm
for the partitioning of a tree with integer-weighted nodes 1
and edges with positive values. Several applications of
the algorithm in the allocation of computer information
to physical storagespaceare suggested.We alsode-
scribe the use of this algorithm in finding a suboptimal
partition of any connectedgraph.
A possible extension of. this algorithm is to find a
computationally efficient method of determining an opti-
mal partition of any graph G based upon the partitioning
of one of the embedded trees of G . Since the tree parti-
,u,, 4
References 3 4
1. P. A. Jensen, Optimal Network Partitioning, Oper. Res.
19,916 (1970). Cost of deleted edgesof G = 4
Cost of partition of T = 3
2. B. W. Kernighan, Some Graph Partitioning Problems Re-
(C)
lated to ProgramSegmentations, PhD. thesis, Princeton
@
University, Princeton, N. J.,January, 1969.
3. 8. W. Kernighan, :Optimal Sequential Partitions of
Graphs,J.ACM18,34 ( 1 9 7 1 ) .
4. E. L. Lawler, Electrical Assemblies With a Minimum 3 4 2
Number of Interconnections, IRE Trans.Elect.Com-
purersC-l1,86 (February 1962).
5. E. t.Lawler, K. N . Levitt, and J. Turner, Module Cluster-
ing to Minimize Delay in Digital Networks, IEEE Trans. Cost = 6
Computers C-18,47 (1969). (d) 223
224