A graph partitioning algorithm divides a problem into two or more subproblems and tries to reduce the interaction between these subproblems. Graph partitioning problem falls under the category of NP-hard problem. In this paper, we are presenting a convex partitioning and mapping algorithm for minimizing cut-size of partitions, for computing and minimizing longest depth of non-convex partitions and for computing longest depth of convex partitions. These problems are NP-hard problems and hence, our convex partitioning and mapping algorithm is a heuristic algorithm to obtain a good solution, or hopefully a near-optimal solution.Convex partitioning and mapping algorithm deals with the task of dividing(partitioning) a given big application graph into two or more parts such that the total number of the edges interconnecting these parts and longest depth of non-convex partitions are minimized while maintaining a given balance constraints among the part size. Convex partitioning and mapping algorithm has many important applications in VLSI design.
Kernighan-Lin[1] proposed a two-way graph partitioning algorithm which became the basis for most of the subsequent partitioning algorithms, all of which we call the KL-based algorithms. Kernighan-Lin's algorithm (KL algorithm) works only on balanced partitions, and performs number of passes over the cells of the circuit until it finds a locally minimum partition. Each pass consists of a repeated operation of pairwise cell swapping for all pairs of cells. Fiduccia-Mattheyses[2] proposed a faster implementation of KL algorithm. FiducciaMattheyses' algorithm (FM algorithm) can operate on unbalanced partitions provided that the part sizes satisfy a particular balance constraint. They also proposed a single cell move instead of a swap of a cell pair at each step in a pass. These modifications as well as proper data structures, like bucket lists, reduced the time complexity of a single pass of KL algorithm to linear in the size of the circuit (the number of pins). Since real circuits are usually very big, KL algorithm is not very efficient for practical use because of its high time complexity, and so the partitioning algorithms proposed after FM algorithm have utilized all the features of FM algorithm. Sanchis[4] proposed a multiway circuit partitioning algorithm based on Krishnamurthy's[3] algorithm so that it could handle the partitioning of a circuit into more than two parts. All the previous approaches before Sanchis' algorithm (FMS algorithm) are originally bipartitioning algorithms. Our proposed convex partitioning and mapping algorithm for graph partitioning is based on FMS algorithm and convexity of graph. Our actual problem is to partition a given application or big graph according to the size of a small resource graph such that each partition is covered by the resource graph. In FMS algorithm, balance criterion of size of partitions state that size of each partition should be in a close integral range. But, we have adopted the balance criterion that allows the size of each partition within interval [0, n’], where n’ is total number of nodes present in resource graph R(V’, E’).
A directed graph G(V, E) consists of a finite non-empty set V of vertices (nodes) and a finite non-empty set E of edges. A directed graph G(V, E) has |V|= n nodes and |E|= m edges. We have assumed that each node , 1 ≤ i ≤ n, has weight 1 and each edge , 1 ≤ j ≤ m has also weight 1. A edge ej is said to be incident to the node if ∈ . If an edge is incident to a node , then we say that is on , or is on . Nodes on an edge are called its terminals, and edges on a node are called its pins. Nodes that share terminals are called neighbor nodes. The degree of a node is equal to the number of edges incident to . The maximum node degree is the biggest value of node degree among all nodes of set V. The degree || of an edge is equal to the number of its terminals. For graph, each edge has 2 terminals. Thus, for graph, degree || of each edge is 2. The total number p of pins, or the total number of terminals, in G(V, E) is defined as
and is taken as the size of the graph. The density D of directed graph G(V, E) with n ≥ 2 is defined as
The density of a graph determines how sparse the graph is, and we say that the smaller the density of a graph, sparser the graph. Given a directed graph G(V, E), we say that π = (, • • • , ) is a k-way partition of G(V, E) if the following three properties hold: each part , 1 ≤ i ≤ k, is a subset of V, parts are pairwise disjoint, and the union of k parts is equal to V. A k-way partition is also called a multiway partition if k > 2, and a bipartition if k = 2. Consider a k-way partition π = (, • • • , ) of a graph G(V, E). The size w() of a part is equal to the total number of nodes in . An edge that has at least one pin in a part is said to connect that part. An edge that connects more than one part is said to be cut, otherwise uncut. The set E(i) of external edges of a part is defined as E(i) = { ϵ E | ∩ ≠ ∅ ^ - ≠ ∅ }, which consists of those cut edges that connect . The set I(i) of internal edges of a part is defined as I(i) = { ϵ E | ∩ ≠ ∅ ^ - = ∅ }, which consists of those uncut edges that connect only . The cost x(𝝅) of a partition 𝝅, also called the cut-size, is equal to the number of cut edges. More formally, x(𝝅) = total number of edges connected to partition 𝝅 - total number of internal edges of partition 𝝅 (i.e. I(𝝅)). Each cut edge contributes an amount of 1 to the cut-size regardless of the number of parts that connects.
The cutstate of an edge indicates whether the edge is cut or uncut. The cutset of a partition is the set of all edges that are cut. Notice that an edge in the cutset must be in the set of external edges of at least two parts. An edge is critical if it has a node such that the node would change the cutstate of the edge if it is moved. Such a move either adds the edge to the cutset or removes the edge from the cutset. We now give the necessary and sufficient condition for an edge to be critical in a k-way partition. Proposition 2.1 An edge ej is critical if and only if either there exists a part such that (s) =2 or there exist two different parts and such that (s) = 1 and (t) = 1, where (s) and (t) are the number of terminals of edge that lie in the partition and respectively. The cutstate of an edge that is not critical cannot be affected by a node move by the definition of a critical edge, and so such a move cannot have any effect (a decrease or an increase) on the cut-size. A move of a node can change the cut-size if the node removes some edges from the cutset, or adds some edges to the cutset, that is, if it alters the cutstate of some edges, which should then be critical edges. Hence, we proved the following proposition. Proposition 2.2 The effect of a move of a node on the cutsize depends only on the critical edges incident to that node. We reflect the effect of a node in the cut-size in terms of its gains, but the gains of a node depends on its costs. Let and be two parts. The cost (s, t) of a node in with respect to is called its external cost if s ≠t and is defined as
where the set (s, t) is the subset of external edges of that would be deleted from the cutset if is moved from to . Hence, the external cost (s, t) of a node in with respect to is equal to the number of edges present in the set (s, t). The cost (s, t) of a node in is called its internal cost if s = t, and is defined as
where the set (s) is the subset of internal edges of that would be added to cutset if is moved from to any other part. Hence, the internal cost (s, s) of a node in is equal to the number of edges present in the set (s). Since can change the cutstate of edges in both (s, t) and (s), those edges are all critical edges. In a k-way partition, each node has only one internal cost but (k- 1) external costs, each of which corresponds to a move direction towards remaining (k-1) parts. The move gain (or gain) (s, t) of a node in with respect to , i.e., the gain of the move of from to , is defined as
where s ≠ t. Note that each node has ( k – 1) move gains in a k-way partition. The maximum move gain is denoted by , and is equal to the product of the maximum node degree and the maximum edge weight. i.e. = × 1 = , where maximum edge weight =1. All the gains fall in the interval [- , ]. Proposition 2.3 Consider the move of node from to . Let the cut-size before and after the move be denoted by x(𝝅) and x'(𝝅), respectively. Then
where (s, t) is the move gain of before the move. As this proposition shows, the gain of a node determines the amount of benefit to be obtained by moving that node. If the gain is positive, the cut-size decreases, but if the gain is negative, it increases.
A partition ∈ π is said to be a convex partition if and only if for each path between node A ∈ and node B ∈ , there exist a node C ∈ then C ∈ , where A ≠ B, C ≠ A and C ≠ B. If a partition ∈ π doesn’t follow above condition then the partition is known as non-convex partition. The union of all convex partitions is represented as convex partition set and the union of all non-convex partitions is represented as non-convex partition set . Thus, we can say that union of set and set represents the partition set π which is given as
The input node of partition is a node which has either no incoming edge or if an edge ∈ E is incoming on then there doesn’t exist a node ∈ for which is outgoing edge. Similarly, the output node vop of partition is a node which has either no outgoing edge or if an edge ∈ E is outgoing from then there doesn’t exist a node ∈ for which is incoming edge. Union of all input nodes of partition set π is represented as input set ∈ V and union of all output nodes of π is represented as output set ∈ V.
We now define the graph covering problem as follows.
Given a big directed graph G(V, E) or application graph and a small directed graph R(V’, E’) or resource graph, we initially produce a k-way partition set π = (, • • •, as the initial solution in which the size w() of each part , 1 ≤ i ≤ k, satisfies the balancing constraint L() ≤ w() ≤ U(). Here, L() and U() are integral lower and upper bounds of size of , respectively. Then we minimize cut-size of partition set π as well as longest depth of non-convex partition set ∈ 𝝅 while maintaining the balancing constraints. All three problems, the multiway graph partitioning problem, convexity detection problem and longest path problem fall under the category of NP-hard problem.
We say that a partition is acceptable if it satisfies the given balance criterion as well as longest depth of non-convex partition set ∈ 𝝅 ≤ longest depth of convex partition set ∈ 𝝅 and unacceptable otherwise. A partition is said to be balanced if the part sizes are in interval [0, n’], and unbalanced otherwise. A partition in which the part sizes are the same as the size of resource graph n’ is called a perfectly balanced partition, but such partition is difficult in some cases because value of n mod n’ may not be 0 and it also depends upon initial random partitioning.
In this section, we discuss about our proposed algorithms and strategies for graph partitioning, convexity detection and longest depth of partition set 𝝅 of G(V, E).
There are two subproblems in the graph partitioning and covering problem. First deals graph partitioning while second deals with convexity detection and longest depth of partition set 𝝅 . We are using the following strategies for graph covering, convexity detection and for longest depth of partition set 𝝅 of G(V, E).
- Create a random initial k-way partition set π = (, • • • , ) of the initial graph G(V, E) while maintaining the balancing constraints of each partition i.e. L() ≤ w() ≤ U() , 1 ≤ i ≤ k.
- Start with an initial partition set π = (, • • • , ). Calculate the initial cost of each node and assume the final cut-size of graph G(V, E) is equal to the initial cut-size.
- At each iteration during a pass, consider all possible moves of each unlock node from its home partition to any of the other (k – 1) partitions and choose the best such move according to the maximum move gain while maintaining the balancing constraints of size of partition. Update the node cost and move gain of all affected nodes. Perform passes until no improvement in cutsize size is obtained.
- For each i, i=1 to k, calculate the every path p between input node ∈ V and output node ∈ V of partition . Check if any node of path p belongs to where ≠ . If such node is found then add the partition to non-convex partition set ∈ π else convex partition set ∈ π. Choose the longest depth among every path p of partition .
- Choose the longest depth of non-convex partition set among the longest depth of each partition ∈ , 1 ≤ i ≤ k. Choose the longest depth of convex partition set among the longest depth of each partition ∈ , 1 ≤ i ≤ k.
- Increment the value of iteration itr by 1.
- Repeat the step 1, step 2, step 3, step 4, step 5 and step 6 until itr becomes maximum or ≤ .
In k-way graph partitioning method, we start with a random initial partition set π = (, • • • , ) and calculate the initial cost of each node of G(V, E). At each step during a pass we consider all possible moves of each node from its source part to any of the other parts in the partition and choose the best such move i.e. the one with the maximum move gain. The selected node is then moved to the target part and is locked for rest of the pass. The node gains of all the affected neighbors are updated accordingly. The next node is chosen in the same way from all the remaining unlocked nodes and is moved to its target part. The node move process is repeated until all the nodes are locked or there are no legal moves available due to the balance constraint. Now maximum gain sum of the selected b nodes is calculated and if is found positive then we make the first b nodes move permanent and improve the cut-size by decreasing it by . Maximum gain sum defines the effect on cut-size after moving first b selected nodes permanently. is equal to the sum of move gains of first b selected nodes. All the nodes moved after the bth node move is reversed to the original part so that the actually moved nodes are the sequence of moving first node from part to part , second node from to ,…, the node from to , where ,....,,,.... ∈ π = (, • • • , ), k is the number of parts. The whole process is called a pass. Several passes are performed until is no longer positive. Then we say that the local optimum with respect to the initial random solution is obtained. The move that do not violate the balance criterion are called legal moves, otherwise illegal. In this method, only legal moves are considered for a move. In k-way partitioning algorithms, each node has (k-1) possible move directions at each step in a pass where each move direction corresponds to a move from its source part to each of the other parts of partition set π. There are k(k-1) possible move directions in total as only the best move is considered in each move direction. An array of pointers, is called bucket array [4], is used for storing move gain for all possible moves. Bucket array is used to keep track of move gain of nodes with respect to their move direction. Since a bucket array stores move gain of all possible moves which fall in interval [- , ].Thus size of bucket array is defined as
We use Initial_Partition algorithm to produce a random initial k-way partition set π=(, • • • , of graph G, where k is the number of parts of partition set π. This algorithm maintains the balancing constraints of each part , 1 ≤ i ≤ k, i.e. L() ≤ w() ≤ U (), where L() and U() are lower and upper bound of size w() of part . We take upper bound U() = n’, where n’ =|V’| and lower bound L() = 0, because each partition should be covered by the resource graph R(V’, E’).The value of k is calculated according to the resource graph R(V’,E’) and application graph G(V,E) and given by
We add 1 to n/n’ because if n mod n’=0, then initial random partitioning creates k parts and each part contains n/n’ nodes which is U() of part . Now if we try to move one node from one partition to another partition to minimize the cut-edges then it is not possible because balance criterion of partition 𝝅 is not be satisfied. However, addition of 1 to n/n’ doesn’t affect the partitioning when n mod n’ ≠ 0. The initial partition set π produced by this algorithm is used in Graph_Covering Algorithm for optimization of cut-size and longest depth .
Non-convexity of a partition increases the inter-connecting edges between and other partitions and it also increases the longest path or critical path of partition . In VLSI circuit design, critical path of partition is a major problem because it increases the cost of circuit design. Minimization of cut-size decreases the number of non-convex parts but critical path remains an issue for circuit designing. After obtaining a local optimum value of cut-size, we try to minimize the longest depth of non-convex partition set using Longest_Depth, Init_Dfs and Dfs algorithms.
We calculate the longest depth of each partition ∈ π using this algorithm. We use a flag to determine whether is convex or non-convex partition. The value of flag is set when partition is non-convex and it is set by Dfs algorithm. At first, we calculate the local longest depth between every input node ∈ and every output node ∈ of partition ∈ 𝝅 using Init_Dfs and Dfs algorithm. From all local longest depth of , we choose a local longest depth with maximum value, is called longest depth of partition . If the value of flag is set then is added to non-convex partition set otherwise is added to convex partition set . This process is repeated for all k partitions. Now, we choose the maximum longest depth among all partitions of , is called longest depth of non-convex partition set . Similarly, we choose a maximum longest depth and a minimum longest depth among all partitions of , are called longest depth and minimum longest depth of convex partition set respectively. The number of all partitions for which flag is set, is called total number of non-convex partitions, is denoted by and defined as
Init_Dfs algorithm is used to initialize the data structures of Dfs algorithms. It creates two temporary arrays, first is, visited array to determine whether a node has been visited before or not and second is, path array to store all nodes of the path between an input node ∈ and an output node ∈ of partition . Initially, all nodes are marked as unvisited. Dfs algorithm is like standard DFS algorithm except some differences. It checks all possible path between an input node ∈ and an output node ∈ . For each path p between and , all nodes in path array are examined that whether node belongs to partition or not. If any node of any path between and doesn’t belongs to then flag is set. A path p with maximum length is selected, is called local longest depth and it is returned to Longest_Depth algorithm.
This is our main algorithm which uses the functionalities provided by all the above algorithms. This algorithm does recursively partitioning to minimize the longest depth . We have assumed the maximum iterations for recursive partitioning is 40. We can’t allow recursive partitioning more than maximum iterations because it increases the time complexity. However, it is practically observed that number of iterations itr lies in interval [1, 15] for most of the graphs. At the starting, a random seed is created and set. An initial k-way partition set π is obtained by using Initial_Partition algorithm. Then the cut-size of initial partition set is minimized by performing several passes on the initial partition set π and it continues until no improvement in cut-size size is obtained. When a local optimum partition set in term of cut-size is obtained, the longest depth of non-convex partition set and longest depth of convex partition set is computed by using Longest_Depth, Init_Dfs and Dfs algorithms and a comparison between and is made. Either if is less than or equal to or itr is greater than maximum iteration then the algorithm produces output and stops otherwise recursive partitioning continues.
This section describes the main data structures used by the algorithms. The below information of node is used by our proposed algorithm. All other data structures are like to the data structure of [4] because we are using k-way partitioning.
- A list for the incoming edges of the node.
- The partition to which the node currently belongs.
- A flag for indicating that whether the node is unlocked or locked.
- If the node is unlocked, a bucket array which points (k-1) move gains associated with each of the (k-1) move directions.
- If the node is unlocked, the gain values of node associated with (k-1) move directions.
- A visited array to determine whether a node has been visited before or not.
- A path array to store all nodes of the path between input and output nodes of partition.
We have computed the longest depth between input node and output node using DFS algorithm. The time complexity may decrease if we use dynamic programming techniques with Dfs algorithm. But it requires extra space of O(n^2) when implementation is done using adjacency matrix. We tried to implement dynamic programming techniques using adjacency matrix representation of graph, we observe that there is a reduction in time complexity for small graphs. But when we use this technique for very big graphs like 20,000 nodes graph, this became infeasible because of memory requirements. So, implementation of dynamic programming may work fine if it is used with adjacency list representation of the graph. One other modification can be suggested as if Dijkstra algorithm is used instead of DFS algorithm then it may give better results for dense graph but it also increases the space complexity and can’t be used for a graph with edge cycle. For sparse graph, Dijkstra algorithm may not give a better result than DFS algorithm.
[1] B.W. Kernighan and S. Lin, " An Efficient Heuristic Procedure for Partitioning Graphs", Bell Systems Technical Journal 49, (February 1970), 291-307.
[2] CM. Fiduccia and R.M. Mattheyses, " A Linear-time Heuristic for Improving Network Partitions", Proc. 19th Design Automation Conference, , 1982, 175-18l.
[3] B. Krishnamurthy, " An Improved Min-Cut Algorithm for Partitioning VLSI Networks", IEEE Transactions on Computers 33, (May 1984), 438-446.
[4] L. A. Sanchis, “Multiple-way network partitioning,” IEEE Trans. Comput., vol. 38, no. 1, pp. 62–81, Jan. 1989.
[5] Ali Dasdan and Cevdet Aykanat, “Two Novel Multiway Circuit Partitioning Algorithms Using Relaxed Locking”, IEEE Transactions On Computer-Aided Design Of Integrated Circuits And Systems, Vol. 16, No. 2, February 1997.
[6] Bruce Hendrickson And Robert Leland, “A Multilevel Algorithm For Partitioning Graphs”, Sandia National Laboratories, Albuquerque, Nm 87185-1110
[7] S.R. Canoy and I.J.L. Garces, “Convex sets under some graph operations, Graphs and Combinatorics”, 18 (4) (2002), 787-793.
[8] M. Changat, H.M. Mulder and G. Sierksma, “Convexities related to path properties on graphs; a unified approach”, Working paper, survey.
[9] M. Farber and R.E. Jamison, “Convexity in graphs and hypergraphs”, SIAM J. Alg. Disc. Math. 7 (3) (1986), 433-444.
[10] Ellis Horowitz, Sartaj Sahni and Sanguthevar Rajasekaran ,”Fundamentals of Computer Algorithms”, Universities Press(India) Private Limited.