The Search Landscape of Graph Partitioning Problems using
The Search Landscape of Graph Partitioning Problems using Coupling and Cohesion as the Clustering Criteria Brian S. Mitchell & Spiros Mancoridis {bmitchel, smancori}@mcs. drexel. edu http: //www. mcs. drexel. edu/~{bmitchel, smancori} Department of Computer Science Software Engineering Research Group http: //serg. mcs. drexel. edu Drexel University, Philadelphia, PA, USA 10/05/2002 1
Software Clustering with Bunch Source Code void main() { printf(“hello”); } Source Code Analysis Tools Acacia Chava Bunch Clustering Tool Bunch GUI Clustering Algorithms Clustering Tools MDG File M 1 M 3 M 2 M 4 M 5 Programming API M 6 M 7 Visualization Tool M 8 Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu Partitioned MDG File M 1 M 3 M 2 M 4 M 5 M 6 M 7 M 8 2
Software Clustering as a Search Problem Source Code void main() { printf(“hello”); } SEARCH SPACE Set of All MDG Partitions M 1 M 3 M 2 Source Code Analysis Tools Acacia Chava M 4 M 8 M 3 M 2 M 4 M 5 M 8 M 4 while(searching()) { p = select. Next(); if(p. is. Better(b. P)) b. P = p; } M 7 “GOOD” MDG Partition M 2 M 6 b. P = null; return b. P; M 6 M 3 M 1 M 7 M 5 M 1 MDG M 6 Software Clustering Search Algorithms M 5 M 1 M 7 M 8 Total = 4140 Partitions M 2 M 4 Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu M 3 M 5 M 6 M 7 M 8 3
The Search Space is Enormous The number of MDG partitions grows very quickly, as the number of modules in the system increases… S n, k 1=1 2=2 3=5 4 = 15 5 = 52 ì 1 =í î Sn-1, k -1 + k. Sn-1, k 6 = 203 7 = 877 8 = 4140 9 = 21147 10 = 115975 if k = 1 Ú k = n otherwise 11 = 678570 12 = 4213597 13 = 27644437 14 = 190899322 15 = 1382958545 16 = 10480142147 17 = 82864869804 18 = 682076806159 19 = 5832742205057 20 = 51724158235372 A 15 Module System is about the limit for performing Exhaustive Analysis Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 4
Our Assumption… “Well designed software systems are organized into cohesive clusters that are loosely interconnected. ” We designed a measurement called MQ that embodies our assumption The MQ measurement balances cohesion and coupling We apply MQ to partitions of the MDG Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 5
Not all Partitions of the MDG are Good Solutions M 1 M 2 MDG M 3 M 4 M 5 Good Partition! M 1 M 4 M 2 M 5 M 3 M 6 Bad Partition! M 1 M 4 M 2 M 6 M 3 M 5 M 6 MQ(Good Partition) > MQ(Bad Partition) Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 6
The Software Clustering Problem: Algorithm Objectives “Find a good partition of the MDG. ” A partition is the decomposition of a set of elements (i. e. , all the nodes of the graph) into mutually disjoint clusters. A good partition is a partition where: n n highly interdependent nodes are grouped in the same clusters independent nodes are assigned to separate clusters The better the partition the higher the MQ Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 7
Generate a Random Decomposition of MDG Neighbor Partition Iteration Step A neighbor partition is created by altering the current partition slightly. Current Partition Measure MQ New Best Neighboring Partition Bunch Hill Climbing Clustering Algorithm Generate Next Neighbor Measure MQ Compare to Best Neighboring Partition Better? Best Neighboring Partition for Iteration Convergence Best Neighboring Partition Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 8
Bunch Hill Climbing Clustering Algorithm Generate a Random Decomposition of MDG Neighbor Partition Iteration Step A neighbor partition is created by altering the current partition slightly. Current Partition We have Measure MQ New Best Neighboring Partition Other Things of Interest Generate Next implemented Neighbora hill-climbing algorithms Measure family of. MQ Compare to Best Neighboring Partition implemented an Exhaustive We also and Genetic Algorithm Better? Best Neighboring Partition for Iteration Convergence Best Neighboring Partition Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 9
Hierarchical Clustering (1): Nested View 1. 4. 2. Default 3. Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 10
Hierarchical Clustering (2): Consolidated View 1. 4. 2. Default 3. Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 11
Hierarchical Clustering (3): Tree View Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 12
Hierarchical Clustering (3): Tree View Observations • The number of levels for a given system’s clustering hierarchy is bounded by: O(log 2 N) because Bunch places at least 2 nodes in each cluster. Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 13
Evaluating The Software Clustering Results Over the past few years we have spent a lot of time evaluating Bunch’s software clustering results n n n Empirically Semi-formally Measuring Similarity Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 14
What We Know Given a particular MDG, the results produced by Bunch converge to a family of related solutions The search space is large, and the probability of finding a good solution by random sampling is infinitesimal Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 15
Software Clustering using Graph Partitioning Techniques Running Bunch multiple times produces a family of related clustering results n Bunch starts with a random partition of the MDG, and makes random moves to explore the search space Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 16
Software Clustering using Graph Partitioning Techniques How related are these clustering results? Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 17
Software Clustering using Graph Partitioning Techniques Given that there are 2, 7644, 437 distinct partitions of this MDG, there is a lot of agreement… Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 18
Software Clustering using Graph Partitioning Techniques Why Some Modules Don’t Agree… Library Modules Isomorphism Omnipresent Module Influences Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 19
Special Modules Isomorphic – Modules that are connected to multiple clusters with equal strength Library – All edges fan-in Driver – All edges fan-out Omnipresent – Modules that are strongly connected to many other modules in the system Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 20
Random Bunch Dot RCS Clustering a System Many Times (1)… Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 21
Random Bunch Swing Clustering a System Many Times (2)… Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 22
Bunch Swing Clustering a System Many Times (2)… Random Bunch Observations • As the number of clusters increased in the random samples, MQ decreased • Bunch converged to a consistent “family” of solutions, no matter where the random starting point was generated • Some solutions were multi-modal • Random solutions were consistently worse than Bunch’s solutions. Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 23
Example - Detailed Results: Bunch System 23% The search space has some inherent structure, as random clusters constrained to the area where Bunch converged did not produce better MQ values. 77% Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 24
Understanding the Search Space There are characteristics of Bunch’s clustering algorithms that are interesting: n n n It seems unusual that the clustering algorithms produce consistent MQ values given the large search space Other approaches [spectral methods] to solving the clustering problem using Bunch’s MQ have not produced better clustering results The median clustering level is a good tradeoff between cluster size and number of clusters w Harman et al. examined using a target granularity [GECCO’ 02] to bias the desired cluster sizes Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 25
Investigating the Search Space Examined multiple systems of different size: n n 15 open source systems developed in C, C++, or Java 13 randomly generated graphs with different properties that we wanted to investigate We clustered each MDG 500 times and examined the clustering data to gain some insight into the search space. Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 26
Example: Median Clustering Level Kerbos v. 5 Cumulative MQ swing Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 27
Example: Median Clustering Level php MQ MQ telnetd Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 28
Example: Median Clustering Level bash mod_ssl ping_libc elm Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu X Axis: MQ Value lynx mailx 29
Example: Median Clustering Level – Random Bipartite Graphs bip-100 -1 bip-100 -25 bip-100 -2 bip-100 -5 bip-100 -75 X Axis: MQ Value Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 30
Example: Median Clustering Level – Random Graphs rnd-100 -1 rnd-100 -25 rnd-100 -2 rnd-100 -5 rnd-100 -75 X Axis: MQ Value Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 31
Example: Median Clustering Level – Random “Circle” Graphs circle-50 circle-100 circle-150 X Axis: MQ Value Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 32
MQ versus #Clusters krb 5 swing bash mod_ssl lynx telnetd ping_libc X Axis: #Clusters Y Axis: MQ Value php elm mailx Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 33
X Axis: #Clusters Y Axis: MQ Value MQ versus #Clusters bip-100 -1 bip-100 -5 bip-100 -25 bip-100 -75 rnd-100 -1 rnd-100 -5 rnd-100 -25 rnd-100 -75 cir-50 cir 100 Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu cir 150 34
Internal- versus External Edges krb 5 swing bash mod_ssl lynx X Axis: External Edges Y Axis: Internal Edges telnetd ping_libc php elm mailx Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 35
Internal- versus External Edges X Axis: External Edges Y Axis: Internal Edges bip-100 -1 bip-100 -5 bip-100 -25 bip-100 -75 rnd-100 -1 rnd-100 -5 rnd-100 -25 rnd-100 -75 cir-50 cir 100 Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu cir 150 36
Real Systems Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 37
Random Systems Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 38
Real Systems Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 39
Random Systems Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 40
What we Learned From Studying the Search Landscape Not all modules are “equal” - Some modules: n n n Are connected to many other modules Are connected to few other modules Have a large fan-in Have a large fan-out Are uniformly connected to other system components Are not uniformly connected to other system components Some modules may have a more “natural” home than other subsystems with respect to their assigned cluster Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 41
What we Learned From Studying the Search Landscape Bunch tends to converge to a consistent solution with respect to MQ n n There is a very low probability of finding one of these partitions by random selection The partitions found by Bunch are a very small subset of the overall search landscape The degree of isomorphism in the clustering results was larger than expected Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 42
What we Learned From Studying the Search Landscape When examining the median level of the clustering hierarchy we observed that all systems tend to converge to at most 2 levels n n n The systems that we studied range from under 100 modules to several thousand modules The number of levels in the clustering hierarchy is bounded by O(log 2 N) We expect that studying systems with several hundred thousand modules would produce results where the median level converges to more than 2 levels. w We observed this in very sparse graphs (e. g. , rnd-100 -1, and bip-100 -1) Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 43
Conclusions (1) Understanding the search landscape is important n n A single run of Bunch is helpful, but it does not highlight modules/classes that tend to drift between clusters Analysis of many Bunch runs helps build a mental model of the search landscape Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 44
Conclusions (2) A best practice for program understanding n n n Cluster a system many times in order to understand the search landscape Identify and separate omnipresent, library and supplier modules Identify that tend to drift between many subsystems w Assign to other clusters manually, or influence the clustering algorithm by adjusting the edge weights w Bunch supports manual and semi-automatic clustering features to help with this type of analysis Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 45
Questions Special Thanks To: n AT&T Research Sun Microsystems DARPA NSF US Army n SEMINAL Group n n Drexel University Software Engineering Research Group (SERG) http: //serg. mcs. drexel. edu 46
- Slides: 46