cazad3011 / Graph-Partitioning-and-Covering-Project

This repo provides information about convex partitioning and mapping technique.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CONVEX PARTITIONING AND MAPPING ALGORITHM

1 Introduction

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.

1.1 Related Work

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’).

2 Basic Definitions and Notations

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 Vi, 1 ≤ i ≤ n, has weight 1 and each edge ej, 1 ≤ j ≤ m has also weight 1. A edge ej is said to be incident to the node Vi if Viej. If an edge ej is incident to a node Vi, then we say that ej is on Vi, or Vi is on ej. 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 di of a node Vi is equal to the number of edges incident to Vi. The maximum node degree dmax is the biggest value of node degree among all nodes of set V. The degree |ej| of an edge ej is equal to the number of its terminals. For graph, each edge has 2 terminals. Thus, for graph, degree |ej| of each edge is 2. The total number p of pins, or the total number of terminals, in G(V, E) is defined as

First equation

and is taken as the size of the graph. The density D of directed graph G(V, E) with n ≥ 2 is defined as

Second equation

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 π = (P1, • • • , Pk) is a k-way partition of G(V, E) if the following three properties hold: each part Pi, 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 π = (P1, • • • , Pk) of a graph G(V, E). The size w(Pi) of a part Pi is equal to the total number of nodes in Pi. 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 Pi is defined as E(i) = {ej ϵ E | ejPi ≠ ∅ ^ ej - Pi ≠ ∅ }, which consists of those cut edges that connect Pi. The set I(i) of internal edges of a part Pi is defined as I(i) = {ej ϵ E | ejPi ≠ ∅ ^ ej - Pi = ∅ }, which consists of those uncut edges that connect only Pi. 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 ej contributes an amount of 1 to the cut-size regardless of the number of parts that ej connects.

2.1 Concept of Cost, Gain and Cut-size

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 Ps such that 𝜹j(s) =2 or there exist two different parts Ps and Pt such that 𝜹j(s) = 1 and 𝜹j(t) = 1, where 𝜹j(s) and 𝜹j(t) are the number of terminals of edge ej that lie in the partition Ps and Pt 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 Ps and Pt be two parts. The cost Ci (s, t) of a node Vi in Ps with respect to Pt is called its external cost if s ≠t and is defined as

Third equation

where the set Ei (s, t) is the subset of external edges of Ps that would be deleted from the cutset if Vi is moved from Ps to Ps. Hence, the external cost Ci (s, t) of a node Vi in Ps with respect to Pt is equal to the number of edges present in the set Ei (s, t). The cost Ci (s, t) of a node Vi in Ps is called its internal cost if s = t, and is defined as

Fourth equation

where the set Ii (s) is the subset of internal edges of Ps that would be added to cutset if Vi is moved from Ps to any other part. Hence, the internal cost Ci (s, s) of a node Vi in Ps is equal to the number of edges present in the set Ii (s). Since Vi can change the cutstate of edges in both Ei (s, t) and Ii (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) Gi (s, t) of a node Vi in Ps with respect to Pt, i.e., the gain of the move of Vi from Ps to Pt, is defined as

Fifth equation

where s ≠ t. Note that each node has ( k – 1) move gains in a k-way partition. The maximum move gain is denoted by Gmax, and is equal to the product of the maximum node degree and the maximum edge weight. i.e. Gmax = dmax × 1 = dmax , where maximum edge weight =1. All the gains fall in the interval [-Gmax , Gmax ]. Proposition 2.3 Consider the move of node from Ps to Pt. Let the cut-size before and after the move be denoted by x(𝝅) and x'(𝝅), respectively. Then

sixth equaltion

where Gi (s, t) is the move gain of Vi 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.

2.2 Concept of convex and non-convex partition

A partition Pcp ∈ π is said to be a convex partition if and only if for each path pAB between node A ∈ Pcp and node B ∈ Pcp , there exist a node C ∈ pAB then C ∈ Pcp, where A ≠ B, C ≠ A and C ≠ B. If a partition Pncp ∈ π doesn’t follow above condition then the partition Pncp is known as non-convex partition. The union of all convex partitions is represented as convex partition set Pc and the union of all non-convex partitions is represented as non-convex partition set Pnc . Thus, we can say that union of set Pc and set Pnc represents the partition set π which is given as

Seventh equation

2.3 Concept of Input and Output node

The input node vip of partition Pi is a node which has either no incoming edge or if an edge eip ∈ E is incoming on vip then there doesn’t exist a node vtPi for which eip is outgoing edge. Similarly, the output node vop of partition Pi is a node which has either no outgoing edge or if an edge eop ∈ E is outgoing from vop then there doesn’t exist a node vtPi for which eop is incoming edge. Union of all input nodes of partition set π is represented as input set vi ∈ V and union of all output nodes of π is represented as output set vo ∈ 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 π = (P1, • • •,Pk as the initial solution in which the size w(Pi) of each part Pi, 1 ≤ i ≤ k, satisfies the balancing constraint L(Pi) ≤ w(Pi) ≤ U(Pi). Here, L(Pi) and U(Pi) are integral lower and upper bounds of size of Pi, respectively. Then we minimize cut-size of partition set π as well as longest depth Lnc of non-convex partition set Pnc ∈ 𝝅 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 Lnc of non-convex partition set Pnc ∈ 𝝅 ≤ longest depth Lc of convex partition set Pc ∈ 𝝅 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.

3 Description of Strategy and Algorithm

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).

3.1 Strategy

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).

  1. Create a random initial k-way partition set π = (P1, • • • , Pk) of the initial graph G(V, E) while maintaining the balancing constraints of each partition Pi i.e. L(Pi) ≤ w(Pi) ≤ U(Pi) , 1 ≤ i ≤ k.
  2. Start with an initial partition set π = (P1, • • • , Pk). 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.
  3. 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.
  4. For each i, i=1 to k, calculate the every path p between input node vi ∈ V and output node vo ∈ V of partition Pi . Check if any node of path p belongs to Pt where PiPt . If such node is found then add the partition Pi to non-convex partition set Pnc ∈ π else convex partition set Pc ∈ π. Choose the longest depth Li among every path p of partition Pi.
  5. Choose the longest depth Lnc of non-convex partition set Pnc among the longest depth Li of each partition PiPnc , 1 ≤ i ≤ k. Choose the longest depth Lc of convex partition set Pc among the longest depth Li of each partition PiPc , 1 ≤ i ≤ k.
  6. Increment the value of iteration itr by 1.
  7. Repeat the step 1, step 2, step 3, step 4, step 5 and step 6 until itr becomes maximum or LncLc .

3.2 A k-way Graph Partitioning

In k-way graph partitioning method, we start with a random initial partition set π = (P1, • • • , Pk) 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 Sb of the selected b nodes is calculated and if Sb is found positive then we make the first b nodes move permanent and improve the cut-size by decreasing it by Sb. Maximum gain sum Sb defines the effect on cut-size after moving first b selected nodes permanently. Sb 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 a1 to part b1, second node from a2 to b2 ,…, the bth node from ab to bb , where a1,a2....ab,b1,b2,....bb ∈ π = (P1, • • • , Pk), k is the number of parts. The whole process is called a pass. Several passes are performed until Sb 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 [-Gmax , Gmax ].Thus size of bucket array is defined as

Eight equation

3.2.1 Initial_Partition Algorithm

We use Initial_Partition algorithm to produce a random initial k-way partition set π=(P1, • • • , Pk of graph G, where k is the number of parts of partition set π. This algorithm maintains the balancing constraints of each part Pi , 1 ≤ i ≤ k, i.e. L(Pi) ≤ w(Pi) ≤ U (Pi), where L(Pi) and U(Pi) are lower and upper bound of size w(Pi) of part Pi. We take upper bound U(Pi) = n’, where n’ =|V’| and lower bound L(Pi) = 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

Ninth equation

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(Pi) of part Pi. 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 Lnc.

3.3 Convexity and longest depth

Non-convexity of a partition Pi increases the inter-connecting edges between Pi and other partitions and it also increases the longest path or critical path of partition Pi. 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 Lnc of non-convex partition set Pnc using Longest_Depth, Init_Dfs and Dfs algorithms.

3.3.1 Longest_Depth Algorithm

We calculate the longest depth of each partition Pi ∈ π using this algorithm. We use a flag to determine whether Pi 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 viPi and every output node voPi of partition Pi ∈ 𝝅 using Init_Dfs and Dfs algorithm. From all local longest depth of Pi, we choose a local longest depth with maximum value, is called longest depth Li of partition Pi. If the value of flag is set then Pi is added to non-convex partition set Pnc otherwise Pi is added to convex partition set Pc . This process is repeated for all k partitions. Now, we choose the maximum longest depth Lnc among all partitions of Pnc, is called longest depth of non-convex partition set Pnc . Similarly, we choose a maximum longest depth Lc and a minimum longest depth Lmc among all partitions of Pc, are called longest depth and minimum longest depth of convex partition set Pc respectively. The number of all partitions for which flag is set, is called total number of non-convex partitions, is denoted by Nncp and defined as

Tenth equation

3.3.2 Init_Dfs and Dfs Algorithm

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 viPi and an output node voPi of partition Pi. 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 viPi and an output node voPi. For each path p between vi and vo , all nodes in path array are examined that whether node belongs to partition Pi or not. If any node of any path between vi and vo doesn’t belongs to Pi 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.

3.4 Convex Partitioning And Mapping 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 Lnc. 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 Lnc of non-convex partition set Pnc and longest depth Lc of convex partition set Pc is computed by using Longest_Depth, Init_Dfs and Dfs algorithms and a comparison between Lnc and Lc is made. Either if Lnc is less than or equal to Lc or itr is greater than maximum iteration then the algorithm produces output and stops otherwise recursive partitioning continues.

4 Data Structure of Algorithm

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.

4.1 Node Data Structure

  1. A list for the incoming edges of the node.
  2. The partition to which the node currently belongs.
  3. A flag for indicating that whether the node is unlocked or locked.
  4. If the node is unlocked, a bucket array which points (k-1) move gains associated with each of the (k-1) move directions.
  5. If the node is unlocked, the gain values of node associated with (k-1) move directions.
  6. A visited array to determine whether a node has been visited before or not.
  7. A path array to store all nodes of the path between input and output nodes of partition.

5 Future Works

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.

6 References

[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.

About

This repo provides information about convex partitioning and mapping technique.