• Tidak ada hasil yang ditemukan

D. Technical Architecture

V. Results 24

As the tool runs, the user is presented with the main menu interface, where the user can choose between starting the analysis or seek information about the tool by clicking the ”help” button.

Figure 8: Main Menu

Figure 9: File Choosing

If the user chooses to add a file, the file chooser interface will immediately pop and direct the user to add the legislator data file it wants.

The user may input any file following the data set format specified in this discourse

(Figure 9).

Figure 10: Features

After the file has been read and parsed, a list of legislator features specified in the data set is shown and the user may choose which of the legislator features will be used to create and evaluate the network of legislators.

Figure 11: Feature Selection

The user may opt to use one, two, or all of the features in the feature list (Figure

11). An error of empty feature set is prompted if the user has not chosen any feature.

Figure 12: Specify Community Parameters

A graph is generated using these feature parameters. An edge is drawn from legislator node to another if there exist a similarity on their features and a unit is added to their edge weight for every similarity thereof. With the graph represented as an adjacency matrix inside the tool, the user is prompted to input the specifications of communities he/she wants to show. An input parameter interface helps this action.

The text field is for the user to input the size of each maximum weighted commu- nities to be displayed .

After specifying the input parameters, the user may choose between approximate

algorithm or exact algorithm to be used in community detection. The approximate

algorithm is much faster than the exact algorithm but the results of it may not be

optimal. In the exact algorithm, if a GPU device is present in the host, the user may

choose where it wants to run the exact algorithm, in the GPU device or the host’s

CPU. Clicking on the generate button yields the following results.

Figure 13: Sample Results

First, the list of the communities and the members under is displayed in a de-

scending order, from highest weight to lowest, which are also displayed beside each

community. The feature/s under consideration for each communities are also dis-

played. Then the user can choose either view the centralities of each nodes, generate

a PDF containing the list of communities and the centrality table, or display the

graph visualization generated from the input data file.

Figure 14: Node Centrality

The node centralities (Degree, Weighted Degree, Betweenness, and Closeness Cen-

trality) is viewed as a table for easier comparison and reading. The table can be sorted

according to the desired centrality.

Figure 15: PDF Input File Name

If the user chooses to export the result as a PDF, he/she is prompted to enter a

desired file name for the PDF file. The file name generated includes the tag of the

tool appended in the beginning.

Figure 16: PDF Generated

A notification pops up suggesting a successful file saving.

Figure 17: PDF Contents

The resulting PDF contains the logo of the software, the author name, and the

date and time of creation. After that page, the results of the software is listed as well

as the centrality table.

Figure 18: Graph Generated

The graph generated can be also viewed as the visual representation of the data

input. The colored entities are the top 5 communities present in the network. The

user can pan the graph by using the arrow keys and zoom using the page up/down

keys.

VI. Discussions

Legislator Clique Finder is a Java-based application that aims to perform community detection in Philippine Congress Legislators by means of clique-finding algorithms.

The basis of the relationship of the members of the community is defined by the similarities present in their different political involvment.

As the data input is placed, the user is given a chance to select the features he/she wants to use to define the relationship of the legislator nodes. After that, the tool generates a graph by building an edge and adding an edge weight for every similarity in the feature that is present between the legislator nodes.

The application provides its users the power to dictate the size of each community to be shown. Other than that, the application also allows the user to choose what algorithm to be used in detecting the said communities, approximate algorithm or the exact algorithm.

The approximate algorithm implemented by the application is the 2-approximation algorithm proposed in [4] that uses the same approach for the RSSM problem and guarantees an optimal result if the edge weights in the adjacency matrix generated follows the metric property. Meanwhile, the exact algorithm uses an exhaustive yet more effective approach by passing through all of the possible node combinations and return the combination with the maximum weight between its nodes. The application provides a GPU implementation for a much faster computation, given that a GPU device is available in the host machine otherwise, a CPU implementation of the exact algorithm is available.

These algorithms are applied and implemented by the tool to generate and detect

the number of desired communities by the user. The application produces three

outputs from user-defined specifications and data. The first one is the community list

where user-defined number of community is displayed along with its members, where

the first community has the largest weight between them. The larger the weight

between nodes in a community means more interaction and similarities happened between them.

The application also provides the user a table of centralities of each nodes. The degree centralities defines the number of direct connections of the nodes, the be- tweenness centrality provides the information on how a node is being used as a bridge between parties, and the closeness centrality defines how close a node is to a more central node. These pieces of information may conclude a more concrete position of each politician in a network.

These results can be exported and saved in a PDF file by choosing the option of generating the PDF file and specifying a file name for the output file.

The GraphStream library of Java provides the visualization of the graph gener- ated from the user input and parameters. It enables a different and convenient point of understanding in viewing and visualizing the said data set by showing some com- munity detected from the network and its ability to be panned and zoomed as well as for its nodes to be moved and placed in a different manner.

There’s an absence of a community detection tool that focuses on political network

that uses clique-finding algorithms. The process of finding one happens to be exhaus-

tive and needs a chunk of the host memory, especially when a network has numerous

nodes. This application provides the initial step in building a wider understanding of

political networks and all of its components.

VII. Conclusions

Legislator Clique Finder is a stand-alone software produced in this study that aims to provide political researchers and analysts a way to view the occurence of highly interactive nodes that forms a community. These community detection can be done using a choice of an algorithm provided and implemented in the software. Aside from that, the software provides a simple graph property extraction by means of node centralities that provides certain information on how each nodes works and interacts in a political network.

This application provides the initiative in helping user visualize and map different

politician involvements for further understanding of relationship as well as discover

interactions, provided by an empirical data, that may be hidden from the public. It

also aims to provide assistance in visualizing and interpreting their gathered data,

and provide a conclusive result that may be used for researches or just provide new

insights and information regarding a political network.

VIII. Recommendations

The proponent suggests that the data set that will be used for further improvements involves a wider variety of political involvements and relationships, such as voting patterns in different congress sessions, for visible diversity of connections that are not easily seen in public data. The data under consideration may be expanded to different political aspects, such as foundations funded, or businesses handled by the legislators, for the software may yield other results that may be useful in studying political relationships.

In terms of network analysis, the proponents suggests researching on community modularity for it measures the strength of network modules such as communities.

Additional implementations of clique-finding algorithms can be also added to simply compare different approaches and results to community detection in Philippine legis- lators. The proponent also suggests that the GPU implementation of algorithms be maximized for the potential of this approach can be useful for faster output generation and analysis.

Lastly, for the visualization aspect, the author recommends viewing the graph

visualization of individual communities, and not just as a part of the network, for

better component analysis and inspection.

IX. Bibliography

[1] H. of Representatives, “Legislative information,”

[2] F. Santo and D. Hric, “Community detection in networks: A user guide,” Physics Reports, vol. 659, pp. 1–44, 2016.

[3] D. Knoke, Political networks: the structural perspective, vol. 4. Cambridge Uni- versity Press, 1994.

[4] E. Gimadi, M. Khachay, and A. V. Kel’manov, “2-approximation algorithm for finding a clique with minimum weigh of vertices and edges,” Proceedings of the Steklov Institute of Mathematics, pp. 87–97, 2014.

[5] F.Hao, D. Park, and Z. Pei, “Exploiting the formation of maximal cliques in social networks,” Symmetry, 2017.

[6] M. Ahuja, J. Singh, and Neha, “Practical applications of community detection,”

International Journal of Advanced Research in Computer Science and Software Engineering, 2016.

[7] F. Santo, “Community detection in graphs,” Physics Reports, vol. 486, pp. 75–

174, 2016.

[8] P. Saxena and D. Thakur, “Complexity analysis of clique problem,” International Journal of Computer Science and Engineering.

[9] R. Ross, D. F. Gleich, and A. H. Gebremedhin, “Parallel maximum clique algo- rithms with applications to network analysis,” Society for Industrial and Applied Mathematics, 2015.

[10] D. Wood, “An algorithm for finding a maximum clique in a graph,” Operations

Research Letters, vol. 21, pp. 211–217, 1997.

[11] D. Palsetia, M. A. Patwary, W. Hendrix, A. Agrawal, and A. Choudhary, “Clique guided community detection,” IEEE International Conference on Big Data, 2014.

[12] M. S. Chang and F. H. Wang, “Efficient algorithms for the maximum weight clique and maximum weight independent set problems of permutation graphs,”

Information Processing letters, vol. 43, pp. 293–295, 1992.

[13] V. Vassilevska, “Efficient algorithms for clique problems,” Information Process- ing Letters, vol. 109, no. 4, pp. 254–257, 2009.

[14] E. M. Hafner-Burton and A. H. Montgomery, “Centrality in politics: How net- works confer power,” OpenSIUC, 2010.

[15] “What went before: The 10-b pork barrel scam,” Philippine Daily Inquirer, 2017.

X. Appendix

A. Source Code

CliqueFinder GUI.java

i m p o r t j a v a x . i m a g e i o . ImageIO ; i m p o r t j a v a x . s w i n g .∗;

i m p o r t j a v a x . s w i n g . f i l e c h o o s e r . F i l e S y s t e m V i e w ; i m p o r t o r g . r o s u d a . REngine . REXPMismatchException ; i m p o r t o r g . r o s u d a . REngine . R s e r v e . R s e r v e E x c e p t i o n ; i m p o r t o r g . g r a p h s t r e a m . g r a p h .∗;

i m p o r t o r g . g r a p h s t r e a m . g r a p h . i m p l e m e n t a t i o n s .∗; i m p o r t j a v a . i o . F i l e ;

i m p o r t j a v a . i o . I O E x c e p t i o n ;

i m p o r t j a v a . n e t . U R I S y n t a x E x c e p t i o n ; i m p o r t j a v a . u t i l . A r r a y L i s t ;

i m p o r t j a v a . awt . B o r d e r L a y o u t ; i m p o r t j a v a . awt . CardLayout ; i m p o r t j a v a . awt . C o l o r ; i m p o r t j a v a . awt . Component ; i m p o r t j a v a . awt . C o n t a i n e r ; i m p o r t j a v a . awt . D i m e n s i o n ; i m p o r t j a v a . awt . Font ;

i m p o r t j a v a . awt . G r i d B a g C o n s t r a i n t s ; i m p o r t j a v a . awt . GridBagLayout ; i m p o r t j a v a . awt . G r i d L a y o u t ; i m p o r t j a v a . awt . Image ; i m p o r t j a v a . awt . I n s e t s ; i m p o r t j a v a . awt . T o o l k i t ; i m p o r t j a v a . awt . e v e n t .∗; p u b l i c c l a s s C l i q u e F i n d e r G U I{

S t r i n g R P a t h P a r s e d = ” ” ; JFrame f r a m e ;

A r r a y L i s t<I n t e g e r> f e a t u r e c o l u m n = new A r r a y L i s t<I n t e g e r>() ; R I n t e g r a t i o n R S E R V E r ;

i n t [ ] s e l e c t e d ;

J T a b l e c e n t r a l i t y t a b l e ;

J S c r o l l P a n e s c r o l l P a n e = new J S c r o l l P a n e ( ) ; J L i s t f e a t u r e L i s t ;

b o o l e a n i s S e l e c t e d ; b o o l e a n i s A v a i l D e v ;

J P a n e l f e a t u r e p a n e l = new J P a n e l ( ) ; Graph g ;

S t r i n g [ ] [ ] d a t a ;

S t r i n g [ ] c o l u m n h e a d e r = {”LEGISLATORS” , ”DEGREE CENTRALITY” , ”WEIGHTED DEGREE CENTRALITY

” , ”BETWEENNESS CENTRALITY” , ”CLOSENESS CENTRALITY”};

A r r a y L i s t<i n t [ ]> c o l o r s = new A r r a y L i s t<i n t [ ]>( ) ;

p u b l i c C l i q u e F i n d e r G U I ( ) t h r o w s R s e r v e E x c e p t i o n , REXPMismatchException { i n t [ ] c o l o r 1 = {2 3 2 , 1 6 , 1 6};

i n t [ ] c o l o r 2 = {1 8 1 , 2 3 2 , 1 6};

i n t [ ] c o l o r 3 = {1 6 , 2 3 2 , 3 0};

i n t [ ] c o l o r 4 = {2 1 4 , 1 6 , 2 3 2};

i n t [ ] c o l o r 5 = {2 3 2 , 1 1 3 , 1 6};

c o l o r s . add ( c o l o r 1 ) ; c o l o r s . add ( c o l o r 2 ) ; c o l o r s . add ( c o l o r 3 ) ; c o l o r s . add ( c o l o r 4 ) ; c o l o r s . add ( c o l o r 5 ) ;

r = new R I n t e g r a t i o n R S E R V E ( ) ; i s S e l e c t e d = f a l s e ;

T o o l k i t t k = T o o l k i t . g e t D e f a u l t T o o l k i t ( ) ; i n t w i n d o w s i z e = t k . g e t S c r e e n R e s o l u t i o n ( ) ;

i n t window x = ( i n t ) ( t k . g e t S c r e e n S i z e ( ) . w i d t h ∗ 0 . 5 0 ) ; i n t window y = ( i n t ) ( t k . g e t S c r e e n S i z e ( ) . h e i g h t ∗ 0 . 7 0 ) ; t r y {

UIManager . s e t L o o k A n d F e e l ( UIManager . g e t S y s t e m L o o k A n d F e e l C l a s s N a m e ( ) ) ; } c a t c h ( C l a s s N o t F o u n d E x c e p t i o n | I n s t a n t i a t i o n E x c e p t i o n | I l l e g a l A c c e s s E x c e p t i o n

| U n s u p p o r t e d L o o k A n d F e e l E x c e p t i o n e ) { e . p r i n t S t a c k T r a c e ( ) ;

}

// C o n t a i n e r s and L a y o u t s C o n t a i n e r box ;

B o r d e r L a y o u t b o r = new B o r d e r L a y o u t ( ) ; G r i d L a y o u t g r i d = new G r i d L a y o u t ( 2 , 0 ) ; CardLayout c a r d = new CardLayout ( ) ; GridBagLayout gb = new GridBagLayout ( ) ;

G r i d B a g C o n s t r a i n t s g b c = new G r i d B a g C o n s t r a i n t s ( ) ;

g b c . i n s e t s = new I n s e t s ( window y / 1 0 0 0 , window x / 1 0 0 , 0 , window x / 1 0 0 ) ; // I c o n s and L a b e l s

Image l o g o = n u l l ; t r y {

l o g o = ImageIO . r e a d ( g e t C l a s s ( ) . g e t R e s o u r c e ( ” / Image / l o g o .PNG” ) ) .

g e t S c a l e d I n s t a n c e ( window x / ( 6 / 5 ) , window y / ( 2 ) , Image . SCALE SMOOTH) ; } c a t c h ( I O E x c e p t i o n e 2 ) {

// TODO Auto−g e n e r a t e d c a t c h b l o c k e 2 . p r i n t S t a c k T r a c e ( ) ;

}

I m a g e I c o n i c o n = new I m a g e I c o n ( l o g o ) ; J L a b e l l o g o D = new J L a b e l ( i c o n ) ; // l o g o D . s e t I c o n ( i c o n ) ;

// l o g o . s e t S i z e ( new D i m e n s i o n ( window x ∗, window y − 4 0 ) ) ;

// Frames

f r a m e = new JFrame ( ” L e g i s l a t o r C l i q u e F i n d e r ” ) ;

JFrame f e a t u r e f r a m e = new JFrame ( ” Choose t h e F e a t u r e s ” ) ; JFrame c e n t r a l i t y f r a m e = new JFrame ( ” C e n t r a l i t i e s ” ) ; box = f r a m e . g e t C o n t e n t P a n e ( ) ;

c e n t r a l i t y f r a m e . s e t S i z e ( new D i m e n s i o n ( window x , window y ) ) ; f e a t u r e f r a m e . s e t S i z e ( 6 0 0 , 5 0 0 ) ;

// T e x t F i e l d s and T e x t A r e a s

J T e x t F i e l d c o m m f i e l d , s i z e f i e l d ; J T e x t A r e a r e s u l t f i e l d = new J T e x t A r e a ( ) ; J T e x t A r e a h e l p a r e a = new J T e x t A r e a ( ) ; r e s u l t f i e l d . s e t S i z e ( 6 0 0 , 5 0 0 ) ; c o m m f i e l d = new J T e x t F i e l d ( ) ;

c o m m f i e l d . s e t T e x t ( ” Number o f Communities ” ) ; s i z e f i e l d = new J T e x t F i e l d ( ) ;

s i z e f i e l d . s e t T e x t ( ” S i z e p e r Community ” ) ;

h e l p a r e a . s e t T e x t ( ” > C l i c k Add f i l e t h e n c h o o s e t h e d a t a s e t . \nMake s u r e t h a t t h e d a t a s e t f o l l o w s t h e d a t a s e t f o r m a t s p e c i f i e d \n > Choose t h e f e a t u r e s you want t o v i s u a l i z e ( At l e a s t 1 ) \n > S p e c i f y t h e community s i z e and number o f community t o be d i s p l a y e d \n> Choose b e t w e e n A p p r o x i m a t e and E x a c t A l g o r i t h m \n> View R e s u l t s and Graph ” ) ;

// P a n e l s

J P a n e l p a n e l = new J P a n e l ( ) ;

J P a n e l s e t I n f o p a n e l = new J P a n e l ( ) ; J P a n e l r e s u l t s p a n e l = new J P a n e l ( ) ; J P a n e l c e n t r a l i t y p a n e l = new J P a n e l ( ) ; J P a n e l h e l p p a n e l = new J P a n e l ( ) ; J P a n e l b u t t o n p a n e l = new J P a n e l ( ) ; // B u t t o n s

J B u t t o n g e n e r a t e b u t t o n = new J B u t t o n ( ” G e n e r a t e ” ) ;

J B u t t o n g e n e r a t e a l l , g e n e r a t e s e l e c t e d , c e n t r a l i t y b u t t o n , s h o w G r a p h b u t t o n , b a c k b u t t o n ;

J B u t t o n s t a r t b u t t o n = new J B u t t o n ( ” S t a r t ” ) ; J B u t t o n h e l p b u t t o n = new J B u t t o n ( ” H e l p ” ) ; b a c k b u t t o n = new J B u t t o n ( ” Back ” ) ;

g e n e r a t e a l l = new J B u t t o n ( ” G e n e r a t e A l l ” ) ;

g e n e r a t e s e l e c t e d = new J B u t t o n ( ” G e n e r a t e S e l e c t e d ” ) ; c e n t r a l i t y b u t t o n = new J B u t t o n ( ” Show C e n t r a l i t y ” ) ; s h o w G r a p h b u t t o n = new J B u t t o n ( ” Show Graph ” ) ;

s t a r t b u t t o n . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( window x / 3 , window y / 6 ) ) ; s t a r t b u t t o n . s e t F o n t ( new Font ( ” A r i a l ” , Font . PLAIN , 1 6 ) ) ;

h e l p b u t t o n . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( window x / 3 , window y / 6 ) ) ; h e l p b u t t o n . s e t F o n t ( new Font ( ” A r i a l ” , Font . PLAIN , 1 6 ) ) ;

//ComboBox

S t r i n g [ ] a l g o b o x S t r i n g = {” A p p r o x i m a t e A l g o r i t h m ” , ” E x a c t A l g o r i t h m (GPU) ” , ” E x a c t A l g o r i t h m (CPU) ”};

JComboBox a l g o b o x = new JComboBox ( a l g o b o x S t r i n g ) ;

J F i l e C h o o s e r j f c = new J F i l e C h o o s e r ( F i l e S y s t e m V i e w . g e t F i l e S y s t e m V i e w ( ) . g e t H o m e D i r e c t o r y ( ) ) ;

b u t t o n p a n e l . s e t L a y o u t ( g r i d ) ;

b u t t o n p a n e l . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( window x / 3 , window y / 3 ) ) ; b u t t o n p a n e l . add ( s t a r t b u t t o n ) ;

b u t t o n p a n e l . add ( h e l p b u t t o n ) ; // r e s u l t s p a n e l . s e t L a y o u t ( b o r ) ; r e s u l t s p a n e l . add ( r e s u l t f i e l d ) ; r e s u l t s p a n e l . add ( c e n t r a l i t y b u t t o n ) ; r e s u l t s p a n e l . add ( b a c k b u t t o n ) ;

// r e s u l t s p a n e l . add ( b u t t o n p a n e l , b o r . PAGE END) ; f e a t u r e f r a m e . add ( g e n e r a t e a l l ) ;

f e a t u r e f r a m e . add ( g e n e r a t e s e l e c t e d ) ; J P a n e l f i l l e r = new J P a n e l ( ) ;

J P a n e l f i l l e r 2 = new J P a n e l ( ) ;

f i l l e r . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( window x / 3 , window y / 5 ) ) ; f i l l e r 2 . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( window x / 3 , window y / 5 ) ) ; f i l l e r . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ;

s e t I n f o p a n e l . s e t L a y o u t ( g r i d ) ; s e t I n f o p a n e l . add ( c o m m f i e l d ) ; s e t I n f o p a n e l . add ( s i z e f i e l d ) ; s e t I n f o p a n e l . add ( a l g o b o x ) ; s e t I n f o p a n e l . add ( b a c k b u t t o n ) ; s e t I n f o p a n e l . add ( g e n e r a t e b u t t o n ) ;

s e t I n f o p a n e l . s e t S i z e ( new D i m e n s i o n ( window x − 1 0 0 , window y − 1 0 0 ) ) ; p a n e l . s e t S i z e ( new D i m e n s i o n ( window x , window y ) ) ;

p a n e l . s e t B a c k g r o u n d ( C o l o r . WHITE) ;

p a n e l . s e t L a y o u t ( new B o r d e r L a y o u t ( 1 0 , 1 0 ) ) ;

p a n e l . s e t B o r d e r ( B o r d e r F a c t o r y . c r e a t e E m p t y B o r d e r ( 6 5 , 0 , 1 1 5 , 0 ) ) ; p a n e l . add ( logoD , B o r d e r L a y o u t . PAGE START) ;

p a n e l . add ( b u t t o n p a n e l , B o r d e r L a y o u t .CENTER) ; p a n e l . add ( f i l l e r 2 , B o r d e r L a y o u t . LINE START ) ; p a n e l . add ( f i l l e r , B o r d e r L a y o u t . LINE END ) ;

g b c . g r i d x = 0 ; g b c . g r i d y = 2 ; g b c . i p a d x = 1 ;

// p a n e l . add ( h e l p b u t t o n , g b c ) ; f r a m e . add ( p a n e l ) ;

f r a m e . s e t S i z e ( new D i m e n s i o n ( window x , window y ) ) ; f r a m e . s e t V i s i b l e ( t r u e ) ;

f r a m e . s e t R e s i z a b l e ( f a l s e ) ;

f r a m e . s e t L o c a t i o n R e l a t i v e T o ( n u l l ) ;

f r a m e . s e t D e f a u l t C l o s e O p e r a t i o n ( JFrame . EXIT ON CLOSE ) ;

h e l p p a n e l . s e t L a y o u t ( new B o r d e r L a y o u t ( ) ) ; h e l p p a n e l . add ( h e l p a r e a , B o r d e r L a y o u t .CENTER) ; h e l p p a n e l . add ( b a c k b u t t o n , B o r d e r L a y o u t . PAGE END) ; h e l p b u t t o n . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){ p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

f r a m e . s e t C o n t e n t P a n e ( h e l p p a n e l ) ; f r a m e . r e v a l i d a t e ( ) ;

f r a m e . r e p a i n t ( ) ; }

}) ;

s t a r t b u t t o n . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){ p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

i n t r e t u r n V a l u e = j f c . sh o w O p e n D i a l o g ( n u l l ) ; i f ( r e t u r n V a l u e == J F i l e C h o o s e r . APPROVE OPTION){

F i l e s e l e c t e d F i l e = j f c . g e t S e l e c t e d F i l e ( ) ;

R P a t h P a r s e d = s e l e c t e d F i l e . g e t A b s o l u t e P a t h ( ) . r e p l a c e ( ’\ \’ , ’ / ’ ) ;

System . o u t . p r i n t l n ( R P a t h P a r s e d ) ; t r y {

r . r e x e c u t e C o n n e c t i o n ( R P a t h P a r s e d ) ;

} c a t c h ( R s e r v e E x c e p t i o n | REXPMismatchException e 1 ) { // TODO Auto−g e n e r a t e d c a t c h b l o c k

e 1 . p r i n t S t a c k T r a c e ( ) ; }

Image i m a g e = n u l l ; t r y {

i m a g e = ImageIO . r e a d ( g e t C l a s s ( ) . g e t R e s o u r c e ( ” / Image / F e a t u r e s .PNG” ) ) . g e t S c a l e d I n s t a n c e ( window x / 2 , window y /4 , Image . SCALE SMOOTH) ; } c a t c h ( I O E x c e p t i o n e 1 ) {

// TODO Auto−g e n e r a t e d c a t c h b l o c k e 1 . p r i n t S t a c k T r a c e ( ) ;

}

I m a g e I c o n i c o n = new I m a g e I c o n ( i m a g e ) ; J L a b e l l o g o = new J L a b e l ( i c o n ) ;

J L i s t j L i s t = new J L i s t ( r . g e t F e a t u r e L i s t ( ) ) ; f e a t u r e L i s t = j L i s t ;

f e a t u r e p a n e l . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( window x , window y ) ) ;

f e a t u r e p a n e l . s e t B a c k g r o u n d ( C o l o r . WHITE) ; f e a t u r e p a n e l . s e t L a y o u t ( gb ) ;

J S c r o l l P a n e f e a t u r e S c r o l l = new J S c r o l l P a n e ( f e a t u r e L i s t ) ; J P a n e l f e a t u r e B u t t o n s = new J P a n e l ( ) ;

f e a t u r e B u t t o n s . add ( g e n e r a t e s e l e c t e d ) ; f e a t u r e B u t t o n s . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ; // f e a t u r e B u t t o n s . add ( b a c k b u t t o n ) ;

f e a t u r e S c r o l l . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( window x / 3 , window y / 3 ) ) ;

f e a t u r e L i s t . s e t F o n t ( new Font ( ” A r i a l ” , Font . PLAIN , 1 6 ) ) ; f e a t u r e p a n e l . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ;

g b c . g r i d x = 0 ; g b c . g r i d y = 0 ;

f e a t u r e p a n e l . add ( l o g o , g b c ) ; g b c . g r i d x = 0 ;

g b c . g r i d y = 1 ;

// g b c . g r i d h e i g h t = 3 ;

f e a t u r e p a n e l . add ( f e a t u r e S c r o l l , g b c ) ; g b c . g r i d x = 0 ;

g b c . g r i d y = 2 ; // g b c . g r i d h e i g h t = 3 ;

f e a t u r e p a n e l . add ( f e a t u r e B u t t o n s , g b c ) ; g b c . g r i d x = 0 ;

g b c . g r i d y = 3 ;

// f e a t u r e p a n e l . add ( b a c k b u t t o n , g b c ) ; // f e a t u r e f r a m e . s e t V i s i b l e ( t r u e ) ; // System . o u t . p r i n t l n ( R P a t h P a r s e d ) ; f r a m e . s e t T i t l e ( ” F e a t u r e S e l e c t i o n ” ) ; // c a r d . show ( box , ” f e a t u r e s ” ) ; f r a m e . s e t C o n t e n t P a n e ( f e a t u r e p a n e l ) ; f r a m e . r e v a l i d a t e ( ) ;

} }

}) ;

g e n e r a t e s e l e c t e d . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){ p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

MWCP Exact GPU m = new MWCP Exact GPU ( ) ; i f (m. getNumOfGPUAvailable ( ) <= 0 ){

JOp tio nPan e . s h o w M e s s a g e D i a l o g ( n u l l , ”GPU A b s e n t ! ” , ”No GPU E r r o r ” , JOp tion Pan e . WARNING MESSAGE) ;

i s A v a i l D e v = f a l s e ; }e l s e{

JOp tio nPan e . s h o w M e s s a g e D i a l o g ( n u l l , m. getNumOfGPUAvailable ( ) + ” GPU D e v i c e / s Found ! ” , ”GPU P r e s e n t ” ,

JO ptio nPa ne . INFORMATION MESSAGE) ; i s A v a i l D e v = t r u e ;

}

i f ( f e a t u r e L i s t . i s S e l e c t i o n E m p t y ( ) == f a l s e ){

s e l e c t e d = new i n t [ f e a t u r e L i s t . g e t S e l e c t e d I n d i c e s ( ) . l e n g t h ] ;

s e l e c t e d = f e a t u r e L i s t . g e t S e l e c t e d I n d i c e s ( ) ; i s S e l e c t e d = t r u e ;

System . o u t . p r i n t l n ( s e l e c t e d . l e n g t h ) ; f o r ( i n t s : s e l e c t e d ){

System . o u t . p r i n t l n ( ” F e a t u r e i n d e x ” + s ) ; }

f r a m e . s e t T i t l e ( ” S e t Community I n f o r m a t i o n ” ) ;

f r a m e . s e t C o n t e n t P a n e ( S e t I n f o P a n e l ( window x , window y , i s A v a i l D e v ) ) ;

f r a m e . r e v a l i d a t e ( ) ; f r a m e . r e p a i n t ( ) ; }e l s e{

JOp tio nPan e . s h o w M e s s a g e D i a l o g ( n u l l , ”You h a v e n o t s e l e c t e d a f e a t u r e ” , ”Empty F e a t u r e S e t ” , J Opti onP ane . WARNING MESSAGE) ;

} }

}) ;

s h o w G r a p h b u t t o n . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){ p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

g . d i s p l a y ( ) ; }

}) ;

b a c k b u t t o n . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){ p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

i f ( f r a m e . g e t C o n t e n t P a n e ( ) . e q u a l s ( s e t I n f o p a n e l ) ){

// f r a m e . r e m o v e A l l ( ) ;

f r a m e . s e t C o n t e n t P a n e ( f e a t u r e p a n e l ) ; f r a m e . r e v a l i d a t e ( ) ;

f r a m e . r e p a i n t ( ) ;

}e l s e i f ( f r a m e . g e t C o n t e n t P a n e ( ) . e q u a l s ( h e l p p a n e l ) ){

// f e a t u r e L i s t . c l e a r S e l e c t i o n ( ) ; f r a m e . s e t C o n t e n t P a n e ( p a n e l ) ; f r a m e . r e v a l i d a t e ( ) ;

f r a m e . r e p a i n t ( ) ;

}e l s e i f ( f r a m e . g e t C o n t e n t P a n e ( ) . e q u a l s ( s c r o l l P a n e ) ){

f r a m e . s e t C o n t e n t P a n e ( s e t I n f o p a n e l ) ; f r a m e . r e v a l i d a t e ( ) ;

f r a m e . r e p a i n t ( ) ; }

} }) ; // p a n e l . }

p u b l i c Graph c o n s t r u c t G r a p h S t r e a m ( A r r a y L i s t<L e g i s l a t o r> l e g i s t , i n t [ ] [ ] r e f m a t r i x ){

Graph g = new S i n g l e G r a p h ( ” P h i l i p p i n e L e g i s l a t o r s Network ” ) ;

g . addNode ( l e g i s t . g e t ( l e g i s t i t e r ) . getName ( ) ) ; }

f o r ( i n t r o w i t e r = 0 ; r o w i t e r < r e f m a t r i x . l e n g t h ; r o w i t e r ++){

f o r ( i n t c o l i t e r = r o w i t e r ; c o l i t e r < r e f m a t r i x [ r o w i t e r ] . l e n g t h ; c o l i t e r ++){

i f ( r e f m a t r i x [ r o w i t e r ] [ c o l i t e r ] != 0 ){

t r y{

g . addEdge ( l e g i s t . g e t ( r o w i t e r ) . getName ( ) + l e g i s t . g e t ( c o l i t e r ) . getName ( ) , l e g i s t . g e t ( r o w i t e r ) . getName ( ) , l e g i s t . g e t ( c o l i t e r ) . getName ( ) ) ;

}c a t c h ( E d g e R e j e c t e d E x c e p t i o n e ){ e . p r i n t S t a c k T r a c e ( ) ; }

} }

}

f o r ( Node node : g ){

node . a d d A t t r i b u t e ( ” u i . l a b e l ” , node . g e t I d ( ) ) ; }

g . a d d A t t r i b u t e ( ” u i . a n t i a l i a s ” ) ; r e t u r n g ;

}

p u b l i c S t r i n g t o D i s p l a y F i e l d ( A r r a y L i s t<L e g i s l a t o r [ ]> r e s u l t , A r r a y L i s t<I n t e g e r> w e i g h t s , i n t n u m b e r o f c o m m u n i t y , i n t c l i q u e s i z e ){

S t r i n g d i s p l a y = ” ” ;

d i s p l a y = d i s p l a y + ( ” Communities a r e Based on : ” ) ; f o r ( S t r i n g s : r . g e t F e a t u r e L i s t ( ) ){

d i s p l a y = d i s p l a y + ”\n”+ s ; }

d i s p l a y = d i s p l a y + ”\n−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−\n ” ; d i s p l a y = d i s p l a y + ( ” Community T o t a l Count : ” + r e s u l t . s i z e ( ) ) ;

f o r ( i n t i t e r a t o r c o m m = 0 ; i t e r a t o r c o m m < r e s u l t . s i z e ( ) ; i t e r a t o r c o m m ++){

d i s p l a y = d i s p l a y + ( ”\n\nCommunity Count : ” + ( i t e r a t o r c o m m + 1 ) ) ; d i s p l a y = d i s p l a y + ( ”\nCommunity Weight : ” + w e i g h t s . g e t ( i t e r a t o r c o m m ) ) ; f o r ( i n t i t e r a t o r l e g = 0 ; i t e r a t o r l e g < r e s u l t . g e t ( i t e r a t o r c o m m ) . l e n g t h ;

i t e r a t o r l e g ++){

d i s p l a y = d i s p l a y + ( ”\n ” + ( i t e r a t o r l e g + 1 ) + ” . ” + r e s u l t . g e t ( i t e r a t o r c o m m ) [ i t e r a t o r l e g ] . getName ( ) ) ;

} }

r e t u r n d i s p l a y ; }

p u b l i c J P a n e l S e t I n f o P a n e l ( i n t width , i n t h e i g h t , b o o l e a n i s A v a i l D e v i c e ){ J L a b e l community , c l i q u e , param , a l g o ;

J P a n e l s e t P a n e l = new J P a n e l ( ) ; s e t P a n e l . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ; Image i m a g e = n u l l ;

J T e x t F i e l d c o m m u n i t y t e x t , c l i q u e t e x t ; JComboBox a l g o r i t h m s ;

J B u t t o n g e n e r a t e , b a c k ;

s e t P a n e l . s e t L a y o u t ( new B o r d e r L a y o u t ( 1 0 , 1 0 ) ) ;

s e t P a n e l . s e t B o r d e r ( B o r d e r F a c t o r y . c r e a t e E m p t y B o r d e r ( 1 0 0 , 1 0 , 1 5 0 , 1 0 ) ) ; s e t P a n e l . s e t F o r e g r o u n d ( C o l o r . WHITE) ;

t r y {

i m a g e = ImageIO . r e a d ( g e t C l a s s ( ) . g e t R e s o u r c e ( ” / Image / C l i q u e P a r a m .PNG” ) ) . g e t S c a l e d I n s t a n c e ( w i d t h / 2 , h e i g h t /4 , Image . SCALE SMOOTH) ;

} c a t c h ( I O E x c e p t i o n e ) {

// TODO Auto−g e n e r a t e d c a t c h b l o c k e . p r i n t S t a c k T r a c e ( ) ;

}

I m a g e I c o n i c o n = new I m a g e I c o n ( i m a g e ) ; param = new J L a b e l ( i c o n ) ;

J P a n e l i n f o P a n e l = new J P a n e l ( ) ; i n f o P a n e l . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ; J P a n e l b u t t o n P a n e l = new J P a n e l ( ) ; b u t t o n P a n e l . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ; J P a n e l f i l l e r P a n e l = new J P a n e l ( ) ; f i l l e r P a n e l . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ; J P a n e l f i l l e r P a n e l 2 = new J P a n e l ( ) ; f i l l e r P a n e l 2 . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ;

f i l l e r P a n e l . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( w i d t h / 5 , h e i g h t / 5 ) ) ; f i l l e r P a n e l 2 . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( w i d t h / 5 , h e i g h t / 5 ) ) ; i n f o P a n e l . s e t L a y o u t ( new BoxLayout ( i n f o P a n e l , BoxLayout . Y AXIS ) ) ; g e n e r a t e = new J B u t t o n ( ” G e n e r a t e ” ) ;

b a c k = new J B u t t o n ( ” Back ” ) ;

community = new J L a b e l ( ” I n p u t d e s i r e d number o f community : ” ) ; community . s e t A l i g n m e n t X ( Component . LEFT ALIGNMENT) ;

c l i q u e = new J L a b e l ( ” I n p u t d e s i r e d community s i z e : ” ) ; c l i q u e . s e t A l i g n m e n t X ( Component . LEFT ALIGNMENT) ;

a l g o = new J L a b e l ( ” Choose what a l g o r i t h m t o be u s e d : ” ) ; a l g o . s e t A l i g n m e n t X ( Component . LEFT ALIGNMENT) ;

c o m m u n i t y t e x t = new J T e x t F i e l d ( ) ; c l i q u e t e x t = new J T e x t F i e l d ( ) ;

i n f o P a n e l . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( w i d t h / 3 , h e i g h t / 5 ) ) ;

i n f o P a n e l . add ( c l i q u e ) ; i n f o P a n e l . add ( c l i q u e t e x t ) ; i n f o P a n e l . add ( a l g o ) ; i f ( i s A v a i l D e v i c e ){

S t r i n g [ ] a l g o b o x S t r i n g = {” A p p r o x i m a t e A l g o r i t h m ” , ” E x a c t A l g o r i t h m (GPU)

” , ” E x a c t A l g o r i t h m (CPU) ”};

a l g o r i t h m s = new JComboBox ( a l g o b o x S t r i n g ) ; }e l s e{

S t r i n g [ ] a l g o b o x S t r i n g = {” A p p r o x i m a t e A l g o r i t h m ” , ” E x a c t A l g o r i t h m (CPU)

”};

a l g o r i t h m s = new JComboBox ( a l g o b o x S t r i n g ) ; }

i n f o P a n e l . add ( a l g o r i t h m s ) ; b u t t o n P a n e l . add ( g e n e r a t e ) ;

s e t P a n e l . add ( param , B o r d e r L a y o u t . PAGE START) ; s e t P a n e l . add ( i n f o P a n e l , B o r d e r L a y o u t .CENTER) ; s e t P a n e l . add ( f i l l e r P a n e l , B o r d e r L a y o u t . LINE START ) ; s e t P a n e l . add ( f i l l e r P a n e l 2 , B o r d e r L a y o u t . LINE END ) ; s e t P a n e l . add ( b u t t o n P a n e l , B o r d e r L a y o u t . PAGE END) ;

g e n e r a t e . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){ p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

r . s e t C l i q u e S i z e ( I n t e g e r . p a r s e I n t ( c l i q u e t e x t . g e t T e x t ( ) ) ) ;

i f ( ( I n t e g e r . p a r s e I n t ( c l i q u e t e x t . g e t T e x t ( ) ) ) < r . g e t L e g i s l a t o r s ( ) . s i z e ( ) ){

t r y {

r . r e x e c u t e ( a l g o r i t h m s .

g e t S e l e c t e d I t e m ( ) . t o S t r i n g ( ) , s e l e c t e d ) ;

} c a t c h ( R s e r v e E x c e p t i o n |

REXPMismatchException e 1 ) {

// TODO Auto−g e n e r a t e d c a t c h b l o c k e 1 . p r i n t S t a c k T r a c e ( ) ;

}

g = c o n s t r u c t G r a p h S t r e a m ( r .

t o T h r o w L e g i s l a t o r , r . t o T h r o w a d j ) ; // g . d i s p l a y ( ) ;

f r a m e . s e t T i t l e ( ” R e s u l t s ” ) ;

f r a m e . s e t C o n t e n t P a n e ( R e s u l t s P a n e l ( width , h e i g h t ) ) ;

f r a m e . r e v a l i d a t e ( ) ; }e l s e{

JOp tio nPan e . s h o w M e s s a g e D i a l o g ( n u l l , ”The c l i q u e s i z e e n t e r e d i s g r e a t e r t h a n t h e number o f n o d e s ” , ” I n v a l i d C l i q u e S i z e ” , JOp tion Pan e . WARNING MESSAGE) ; }

} }) ;

b a c k . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){ p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

f r a m e . s e t C o n t e n t P a n e ( f e a t u r e p a n e l ) ; f r a m e . r e v a l i d a t e ( ) ;

f r a m e . r e p a i n t ( ) ; }

}) ;

r e t u r n s e t P a n e l ; }

p u b l i c J P a n e l R e s u l t s P a n e l ( i n t width , i n t h e i g h t ){

J P a n e l r e s u l t s P a n e l = new J P a n e l ( ) ; r e s u l t s P a n e l . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ; J B u t t o n graph , c e n t r a l i t y , b a c k ;

J S c r o l l P a n e s c r o l l e r ;

J T e x t A r e a r e s u l t F i e l d = new J T e x t A r e a ( ) ; Image i m a g e = n u l l ;

t r y {

i m a g e = ImageIO . r e a d ( g e t C l a s s ( ) . g e t R e s o u r c e ( ” / Image / R e s u l t s .PNG” ) ) . g e t S c a l e d I n s t a n c e ( w i d t h / 2 , h e i g h t /4 , Image . SCALE SMOOTH) ; } c a t c h ( I O E x c e p t i o n e ) {

// TODO Auto−g e n e r a t e d c a t c h b l o c k e . p r i n t S t a c k T r a c e ( ) ;

}

I m a g e I c o n i c o n = new I m a g e I c o n ( i m a g e ) ; J L a b e l l o g o = new J L a b e l ( i c o n ) ; J P a n e l b u t t o n P a n e l = new J P a n e l ( ) ; b u t t o n P a n e l . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ; J P a n e l f i l l e r P a n e l = new J P a n e l ( ) ; f i l l e r P a n e l . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ; J P a n e l f i l l e r P a n e l 2 = new J P a n e l ( ) ; f i l l e r P a n e l 2 . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ;

f i l l e r P a n e l . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( w i d t h / 5 , h e i g h t / 5 ) ) ; f i l l e r P a n e l 2 . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( w i d t h / 5 , h e i g h t / 5 ) ) ;

r e s u l t F i e l d . s e t T e x t ( t o D i s p l a y F i e l d ( r . g e t R e s u l t s ( ) , r . g e t R e s u l t W e i g h t s ( ) , r . getNumberOfCommunities ( ) , r . g e t C l i q u e S i z e ( ) ) ) ;

r e s u l t F i e l d . s e t F o n t ( new Font ( ” A r i a l ” , Font . PLAIN , 1 4 ) ) ; s c r o l l e r = new J S c r o l l P a n e ( r e s u l t F i e l d ) ;

g r a p h = new J B u t t o n ( ” Show Graph ” ) ;

c e n t r a l i t y = new J B u t t o n ( ” Show C e n t r a l i t y ” ) ; b a c k = new J B u t t o n ( ” Back ” ) ;

J B u t t o n p d f = new J B u t t o n ( ” G e n e r a t e PDF” ) ; b u t t o n P a n e l . add ( g r a p h ) ;

b u t t o n P a n e l . add ( c e n t r a l i t y ) ; b u t t o n P a n e l . add ( p d f ) ; b u t t o n P a n e l . add ( b a c k ) ;

r e s u l t s P a n e l . s e t L a y o u t ( new B o r d e r L a y o u t ( 1 0 , 1 0 ) ) ;

r e s u l t s P a n e l . s e t B o r d e r ( B o r d e r F a c t o r y . c r e a t e E m p t y B o r d e r ( 1 0 , 1 0 , 1 0 , 1 0 ) ) ; r e s u l t s P a n e l . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( width , h e i g h t ) ) ;

r e s u l t s P a n e l . s e t F o r e g r o u n d ( C o l o r . WHITE) ;

r e s u l t s P a n e l . add ( l o g o , B o r d e r L a y o u t . PAGE START) ; r e s u l t s P a n e l . add ( s c r o l l e r , B o r d e r L a y o u t .CENTER) ; r e s u l t s P a n e l . add ( f i l l e r P a n e l , B o r d e r L a y o u t . LINE START ) ; r e s u l t s P a n e l . add ( f i l l e r P a n e l 2 , B o r d e r L a y o u t . LINE END ) ; r e s u l t s P a n e l . add ( b u t t o n P a n e l , B o r d e r L a y o u t . PAGE END) ; g r a p h . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){

p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

// i n t C l i q u e C o u n t e r = 0 ; i n t bound = 5 ;

i f ( r . g e t R e s u l t s ( ) . s i z e ( ) < bound ){

bound = r . g e t R e s u l t s ( ) . s i z e ( ) ; }

f o r ( i n t C l i q u e C o u n t e r = 0 ; C l i q u e C o u n t e r < bound ; C l i q u e C o u n t e r ++){

f o r ( i n t n o d e C o u n t e r = 0 ; n o d e C o u n t e r< r . g e t R e s u l t s ( ) . g e t ( 0 ) . l e n g t h ; n o d e C o u n t e r++){

L e g i s l a t o r [ ] l = r . g e t R e s u l t s ( ) . g e t ( C l i q u e C o u n t e r ) ; g . g e t N o d e ( l [ n o d e C o u n t e r ] . getName ( ) ) . a d d A t t r i b u t e ( ” u i . s t y l e

” , ” f i l l−c o l o r : r g b ( ” + c o l o r s . g e t ( C l i q u e C o u n t e r ) [ 0 ] +

” ,”+ c o l o r s . g e t ( C l i q u e C o u n t e r ) [ 1 ] + ” ,”+ c o l o r s . g e t ( C l i q u e C o u n t e r ) [ 2 ] + ” ) ; s i z e : 20 px ; ” ) ;

f o r ( i n t n o d e C o u n t e r 2 = n o d e C o u n t e r + 1 ; n o d e C o u n t e r 2 < r . g e t R e s u l t s ( ) . g e t ( 0 ) . l e n g t h ; n o d e C o u n t e r 2++){

g . g e t N o d e ( l [ n o d e C o u n t e r ] . getName ( ) ) . g e t E d g e B e t w e e n ( l [ n o d e C o u n t e r 2 ] . getName ( ) ) . a d d A t t r i b u t e ( ” u i . s t y l e ” , ” f i l l−c o l o r : r g b ( ” + c o l o r s . g e t ( C l i q u e C o u n t e r ) [ 0 ] +

” ,”+ c o l o r s . g e t ( C l i q u e C o u n t e r ) [ 1 ] + ” ,”+ c o l o r s . g e t ( C l i q u e C o u n t e r ) [ 2 ] + ” ) ; s h a p e : b l o b ; ” ) ;

} }

}

g . d i s p l a y ( ) ; }

}) ;

p d f . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){

p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

i n t [ ] dc = r . g e t D e g C e n t r a l i t y ( ) ; d o u b l e [ ] c c = r . g e t C l o C e n t r a l i t y ( ) ; d o u b l e [ ] bc = r . g e t B e t C e n t r a l i t y ( ) ; i n t [ ] dwc = r . g e t D e g W e i g h t e d ( ) ;

d a t a = new S t r i n g [ r . g e t L e g i s l a t o r s ( ) . s i z e ( ) ] [ 5 ] ;

f o r ( i n t r o w i t e r = 0 ; r o w i t e r < r . g e t L e g i s l a t o r s ( ) . s i z e ( ) ; r o w i t e r ++){

d a t a [ r o w i t e r ] [ 0 ] = r . g e t L e g i s l a t o r s ( ) . g e t ( r o w i t e r ) . getName ( ) ;

d a t a [ r o w i t e r ] [ 1 ] = I n t e g e r . t o S t r i n g ( dc [ r o w i t e r ] ) ; d a t a [ r o w i t e r ] [ 2 ] = I n t e g e r . t o S t r i n g ( dwc [ r o w i t e r ] ) ; d a t a [ r o w i t e r ] [ 3 ] = D o u b l e . t o S t r i n g ( c c [ r o w i t e r ] ) ; d a t a [ r o w i t e r ] [ 4 ] = D o u b l e . t o S t r i n g ( bc [ r o w i t e r ] ) ; }

S t r i n g name = J Opti onP ane . s h o w I n p u t D i a l o g ( ” I n p u t F i l e name : ” ) ; S t r i n g f i l e N a m e = ” [ LCF ] ” + name +” R e s u l t s . p d f ” ;

ReportMaker r = new ReportMaker ( f i l e N a m e , System . g e t P r o p e r t y ( ” u s e r . name ” ) , c o l u m n h e a d e r , d a t a ) ;

r . makeReport ( r e s u l t F i e l d . g e t T e x t ( ) ) ;

JO ptio nPa ne . s h o w M e s s a g e D i a l o g ( n u l l , ”PDF G e n e r a t e d ! ” , ” S u c c e s s ! ” , JOp tio nPan e . INFORMATION MESSAGE) ;

} }) ;

c e n t r a l i t y . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){ p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

f r a m e . s e t C o n t e n t P a n e ( c e n t r a l i t y P a n e l ( width , h e i g h t ) ) ; f r a m e . r e v a l i d a t e ( ) ;

f r a m e . r e p a i n t ( ) ;

}

}) ;

b a c k . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){ p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

f r a m e . s e t T i t l e ( ” S e t C l i q u e I n f o r m a t i o n ” ) ;

f r a m e . s e t C o n t e n t P a n e ( S e t I n f o P a n e l ( width , h e i g h t , i s A v a i l D e v ) ) ; f r a m e . r e v a l i d a t e ( ) ;

f r a m e . r e p a i n t ( ) ; }

}) ;

r e t u r n r e s u l t s P a n e l ;

}

p u b l i c J P a n e l c e n t r a l i t y P a n e l ( i n t width , i n t h e i g h t ){

J P a n e l c e n t r a l i t y P = new J P a n e l ( ) ; c e n t r a l i t y P . s e t B a c k g r o u n d ( C o l o r . w h i t e ) ; J B u t t o n b a c k b u t t o n = new J B u t t o n ( ” Back ” ) ; c e n t r a l i t y P . s e t L a y o u t ( new B o r d e r L a y o u t ( ) ) ;

c e n t r a l i t y P . s e t P r e f e r r e d S i z e ( new D i m e n s i o n ( width , h e i g h t ) ) ; c e n t r a l i t y P . s e t F o r e g r o u n d ( C o l o r . WHITE) ;

Image i m a g e = n u l l ; t r y {

i m a g e = ImageIO . r e a d ( g e t C l a s s ( ) . g e t R e s o u r c e ( ” / Image / C e n t r a l i t y .PNG” ) ) . g e t S c a l e d I n s t a n c e ( w i d t h / 2 , h e i g h t /4 , Image . SCALE SMOOTH) ;

} c a t c h ( I O E x c e p t i o n e 1 ) {

// TODO Auto−g e n e r a t e d c a t c h b l o c k e 1 . p r i n t S t a c k T r a c e ( ) ;

}

I m a g e I c o n i c o n = new I m a g e I c o n ( i m a g e ) ; J L a b e l l o g o = new J L a b e l ( i c o n ) ; J S c r o l l P a n e s c r o l l P a n e ;

i n t [ ] dc = r . g e t D e g C e n t r a l i t y ( ) ; d o u b l e [ ] c c = r . g e t C l o C e n t r a l i t y ( ) ; d o u b l e [ ] bc = r . g e t B e t C e n t r a l i t y ( ) ; i n t [ ] dwc = r . g e t D e g W e i g h t e d ( ) ;

d a t a = new S t r i n g [ r . g e t L e g i s l a t o r s ( ) . s i z e ( ) ] [ 5 ] ;

f o r ( i n t r o w i t e r = 0 ; r o w i t e r < r . g e t L e g i s l a t o r s ( ) . s i z e ( ) ; r o w i t e r ++){

d a t a [ r o w i t e r ] [ 0 ] = r . g e t L e g i s l a t o r s ( ) . g e t ( r o w i t e r ) . getName ( ) ; d a t a [ r o w i t e r ] [ 1 ] = I n t e g e r . t o S t r i n g ( dc [ r o w i t e r ] ) ;

d a t a [ r o w i t e r ] [ 2 ] = I n t e g e r . t o S t r i n g ( dwc [ r o w i t e r ] ) ; d a t a [ r o w i t e r ] [ 3 ] = D o u b l e . t o S t r i n g ( c c [ r o w i t e r ] ) ; d a t a [ r o w i t e r ] [ 4 ] = D o u b l e . t o S t r i n g ( bc [ r o w i t e r ] ) ; }

c e n t r a l i t y t a b l e = new J T a b l e ( d a t a , c o l u m n h e a d e r ){

/∗∗

∗/

p r i v a t e s t a t i c f i n a l l o n g s e r i a l V e r s i o n U I D = −4 3 5 9 1 0 0 1 0 9 0 7 9 9 7 9 7L ; p u b l i c b o o l e a n i s C e l l E d i t a b l e ( i n t row , i n t column ){

r e t u r n f a l s e ; }

};

c e n t r a l i t y t a b l e . s e t A u t o C r e a t e R o w S o r t e r ( t r u e ) ; s c r o l l P a n e = new J S c r o l l P a n e ( c e n t r a l i t y t a b l e ) ; c e n t r a l i t y P . add ( l o g o , B o r d e r L a y o u t . PAGE START) ; c e n t r a l i t y P . add ( s c r o l l P a n e , B o r d e r L a y o u t .CENTER) ; c e n t r a l i t y P . add ( b a c k b u t t o n , B o r d e r L a y o u t . PAGE END) ; b a c k b u t t o n . a d d A c t i o n L i s t e n e r ( new A c t i o n L i s t e n e r ( ){

p u b l i c v o i d a c t i o n P e r f o r m e d ( A c t i o n E v e n t e ){

f r a m e . s e t T i t l e ( ” S e t C l i q u e I n f o r m a t i o n ” ) ;

f r a m e . s e t C o n t e n t P a n e ( R e s u l t s P a n e l ( width , h e i g h t ) ) ; f r a m e . r e v a l i d a t e ( ) ;

f r a m e . r e p a i n t ( ) ; }

}) ;

r e t u r n c e n t r a l i t y P ; }

}

CliqueFinder Main.java

i m p o r t o r g . r o s u d a . REngine . REXPMismatchException ; i m p o r t o r g . r o s u d a . REngine . R s e r v e . R s e r v e E x c e p t i o n ; p u b l i c c l a s s C l i q u e F i n d e r M a i n {

p u b l i c s t a t i c v o i d main ( S t r i n g [ ] a r g s ) t h r o w s R s e r v e E x c e p t i o n , REXPMismatchException{

System . o u t . p r i n t l n ( ” r e s u l t =”+R C o n n e c t o r . c h e c k L o c a l R s e r v e ( ) ) ;

System . s e t P r o p e r t y ( ” o r g . g r a p h s t r e a m . u i . r e n d e r e r ” , ” o r g . g r a p h s t r e a m . u i . j 2 d v i e w e r .

C l i q u e F i n d e r G U I g = new C l i q u e F i n d e r G U I ( ) ; }

}

Graph Construction.java

i m p o r t j a v a . u t i l . A r r a y L i s t ; p u b l i c c l a s s G r a p h C o n s t r u c t i o n {

p u b l i c G r a p h C o n s t r u c t i o n ( ){ }

p u b l i c i n t [ ] [ ] c o n s t r u c t a d j a c e n c y m a t r i x ( A r r a y L i s t<L e g i s l a t o r> l e g i s l a t o r s ){ i n t [ ] [ ] a d j m a t r i x = new i n t [ l e g i s l a t o r s . s i z e ( ) ] [ l e g i s l a t o r s . s i z e ( ) ] ;

f o r ( i n t i n d e x r o w = 0 ; i n d e x r o w < l e g i s l a t o r s . s i z e ( ) ; i n d e x r o w ++){

f o r ( i n t l e g i s l a t o r i t e r a t o r = 0 ; l e g i s l a t o r i t e r a t o r < l e g i s l a t o r s . s i z e ( ) ; l e g i s l a t o r i t e r a t o r ++){

a d j m a t r i x [ i n d e x r o w ] [ l e g i s l a t o r i t e r a t o r ] = 0 ; f o r ( i n t i n d e x c o l = 0 ; i n d e x c o l < l e g i s l a t o r s . g e t ( 0 ) .

g e t F e a t u r e s ( ) . s i z e ( ) ; i n d e x c o l ++){

i f ( ( l e g i s l a t o r s . g e t ( i n d e x r o w ) . g e t F e a t u r e ( i n d e x c o l ) . e q u a l s ( l e g i s l a t o r s . g e t (

l e g i s l a t o r i t e r a t o r ) . g e t F e a t u r e ( i n d e x c o l ) ) )

&& ( l e g i s l a t o r i t e r a t o r != i n d e x r o w ) ){ a d j m a t r i x [ i n d e x r o w ] [ l e g i s l a t o r i t e r a t o r ]

+= 1 ; }

} }

}

r e t u r n a d j m a t r i x ; }

p u b l i c i n t [ ] [ ] c o n s t r u c t a d j a c e n c y m a t r i x c h o s e n ( A r r a y L i s t<L e g i s l a t o r> l e g i s l a t o r s , A r r a y L i s t<I n t e g e r> f e a t u r e c o l u m n ){

i n t [ ] [ ] a d j m a t r i x = new i n t [ l e g i s l a t o r s . s i z e ( ) ] [ l e g i s l a t o r s . s i z e ( ) ] ; f o r ( i n t i n d e x r o w = 0 ; i n d e x r o w < l e g i s l a t o r s . s i z e ( ) ; i n d e x r o w ++){

f o r ( i n t l e g i s l a t o r i t e r a t o r = i n d e x r o w ; l e g i s l a t o r i t e r a t o r < l e g i s l a t o r s . s i z e ( ) ; l e g i s l a t o r i t e r a t o r ++){

a d j m a t r i x [ i n d e x r o w ] [ l e g i s l a t o r i t e r a t o r ] = 0 ;

f o r ( i n t f e a t u r e i t e r a t o r = 0 ; f e a t u r e i t e r a t o r < f e a t u r e c o l u m n . s i z e ( ) ; f e a t u r e i t e r a t o r ++){

i f ( l e g i s l a t o r s . g e t ( i n d e x r o w ) . g e t F e a t u r e ( f e a t u r e c o l u m n . g e t ( f e a t u r e i t e r a t o r ) ) . e q u a l s ( l e g i s l a t o r s . g e t ( l e g i s l a t o r i t e r a t o r ) . g e t F e a t u r e ( f e a t u r e c o l u m n . g e t ( f e a t u r e i t e r a t o r ) ) ) && ( l e g i s l a t o r i t e r a t o r !=

i n d e x r o w ) ){

a d j m a t r i x [ i n d e x r o w ] [ l e g i s l a t o r i t e r a t o r ] += 1 ; a d j m a t r i x [ l e g i s l a t o r i t e r a t o r ] [ i n d e x r o w ] += 1 ; }

} }

}

r e t u r n a d j m a t r i x ; }

p u b l i c v o i d p r i n t A d j ( i n t [ ] [ ] a d j m a t r i x ){

f o r ( i n t i n d e x r o w = 0 ; i n d e x r o w < a d j m a t r i x . l e n g t h ; i n d e x r o w ++){

f o r ( i n t i n d e x c o l = 0 ; i n d e x c o l < a d j m a t r i x [ 1 ] . l e n g t h ; i n d e x c o l ++){

System . o u t . p r i n t ( ” ” + a d j m a t r i x [ i n d e x r o w ] [ i n d e x c o l ] ) ; }

System . o u t . p r i n t ( ”\n ” ) ; }

}

p u b l i c S t r i n g g r a p h e x p ( i n t [ ] [ ] a d j m a t r i x ){ S t r i n g B u i l d e r s b = new S t r i n g B u i l d e r ( ) ; // i n t i n d e x c o l = 0 ;

// i n t r o w l e n g t h = a d j

f o r ( i n t i n d e x r o w = 0 ; i n d e x r o w < a d j m a t r i x . l e n g t h ; i n d e x r o w ++){

f o r ( i n t i n d e x c o l = i n d e x r o w ; i n d e x c o l < a d j m a t r i x [ 1 ] . l e n g t h ; i n d e x c o l ++){

i f ( ( a d j m a t r i x [ i n d e x r o w ] [ i n d e x c o l ] != 0 ) ){

s b . append ( ( i n d e x r o w + 1 ) + ” , ” + ( i n d e x c o l + 1 ) + ” , ” ) ; }

} }

S t r i n g e x p r e s s i o n = s b . t o S t r i n g ( ) ;

r e t u r n e x p r e s s i o n . s u b s t r i n g ( 0 , e x p r e s s i o n . l e n g t h ( )−1) ; }

}

Legislator.java

i m p o r t j a v a . u t i l . A r r a y L i s t ; p u b l i c c l a s s L e g i s l a t o r {

S t r i n g name ;

A r r a y L i s t<S t r i n g> f e a t u r e s = new A r r a y L i s t<S t r i n g>() ; p u b l i c L e g i s l a t o r ( ){

}

p u b l i c v o i d setName ( S t r i n g i n a m e ){ name = i n a m e ;

}

p u b l i c S t r i n g getName ( ){ r e t u r n name ; }

p u b l i c v o i d s e t F e a t u r e ( A r r a y L i s t<S t r i n g> i f e a t u r e s ){ f e a t u r e s = i f e a t u r e s ;

}

p u b l i c A r r a y L i s t<S t r i n g> g e t F e a t u r e s ( ){ r e t u r n f e a t u r e s ;

}

p u b l i c S t r i n g g e t F e a t u r e ( i n t i n d e x ){ r e t u r n f e a t u r e s . g e t ( i n d e x ) ; }

}

MWCP Approx Algorithm.java

i m p o r t j a v a . u t i l . A r r a y s ;

i m p o r t j a v a . u t i l . s t r e a m . I n t S t r e a m ; i m p o r t j a v a . u t i l . A r r a y L i s t ;

// i m p o r t o r g . a p a c h e . commons . l a n g 3 . A r r a y U t i l s ; p u b l i c c l a s s MWCP Approx Algorithm {

p u b l i c MWCP Approx Algorithm ( ){ }

A r r a y L i s t<I n t e g e r> f i n a l w e i g h t s = new A r r a y L i s t<I n t e g e r>() ;

p u b l i c A r r a y L i s t<L e g i s l a t o r [ ]> a p p r o x a l g o r i t h m ( A r r a y L i s t<L e g i s l a t o r> l e g i s l a t o r s , i n t [ ] [ ] a d j m a t r i x 1 , i n t c l i q u e s i z e ){

A r r a y L i s t<L e g i s l a t o r [ ]> r e s u l t s = new A r r a y L i s t<L e g i s l a t o r [ ]>( ) ; A r r a y L i s t<i n t [ ]> k e y s = new A r r a y L i s t<i n t [ ]>( ) ;

A r r a y L i s t<I n t e g e r> s u m b u f f e r = new A r r a y L i s t<I n t e g e r>() ; A r r a y L i s t<I n t e g e r> m a x i n t = new A r r a y L i s t<I n t e g e r>() ; A r r a y L i s t<I n t e g e r> s u m i n t = new A r r a y L i s t<I n t e g e r>() ; // A r r a y L i s t<I n t e g e r> k e y s l i s t = new A r r a y L i s t<I n t e g e r>() ; // System . o u t . p r i n t l n ( ”Comm s i z e : ” + n u m b e r o f c o m m u n i t i e s ) ; I n t e g e r [ ] s u m a r r a y = new I n t e g e r [ a d j m a t r i x 1 . l e n g t h ] ; i n t [ ] k e y a r r a y = new i n t [ c l i q u e s i z e ] ;

i n t [ ] [ ] a d j b u f f e r = new i n t [ a d j m a t r i x 1 . l e n g t h ] [ a d j m a t r i x 1 . l e n g t h ] ; f o r ( i n t column = 0 ; column < a d j m a t r i x 1 . l e n g t h ; column++){

f o r ( i n t row = 0 ; row < a d j m a t r i x 1 [ column ] . l e n g t h ; row++){

a d j b u f f e r [ row ] [ column ] = a d j m a t r i x 1 [ row ] [ column ] ; }

}

// S o r t e a c h row i n t h e a d j a c e n c y m a t r i x t h e n g e t t h e d e s i r e d number o f v e r t i c e s System . o u t . p r i n t l n ( ” A d j a c e n c y M a t r i x S o r t e d ” ) ;

f o r ( i n t c l i q u e i t e r a t o r = 0 ; c l i q u e i t e r a t o r < a d j m a t r i x 1 [ 0 ] . l e n g t h ; c l i q u e i t e r a t o r ++){

// a d j b u f f e r = a d j m a t r i x [ c l i q u e i t e r a t o r ] ; A r r a y s . s o r t ( a d j b u f f e r [ c l i q u e i t e r a t o r ] ) ; i n t [ ] r o w b u f f e r = new i n t [ c l i q u e s i z e ] ;

f o r ( i n t v e r t e x i t e r a t o r = 0 ; v e r t e x i t e r a t o r < c l i q u e s i z e ; v e r t e x i t e r a t o r ++){

r o w b u f f e r [ v e r t e x i t e r a t o r ] = a d j b u f f e r [ c l i q u e i t e r a t o r ] [ a d j b u f f e r [ 0 ] . l e n g t h − v e r t e x i t e r a t o r − 1 ] ;

}

k e y s . add ( r o w b u f f e r ) ; }

System . o u t . p r i n t l n ( ” A d j a c e n c y M a t r i x S o r t e d ” ) ; System . o u t . p r i n t l n ( ” Compute a r r a y sum Done ! ” ) ;

// Get t h e sum o f e a c h a r r a y and s t o r e i t on an a r r a y l i s t f o r i n d e x r e f e r e n c e , and i n t e g e r a r r a y f o r s o r t i n g

f o r ( i n t s u m b u f f e r i t e r a t o r = 0 ; s u m b u f f e r i t e r a t o r < k e y s . s i z e ( ) ; s u m b u f f e r i t e r a t o r ++){

s u m b u f f e r . add ( I n t S t r e a m . o f ( k e y s . g e t ( s u m b u f f e r i t e r a t o r ) ) . sum ( ) ) ;

s u m a r r a y [ s u m b u f f e r i t e r a t o r ] = I n t S t r e a m . o f ( k e y s . g e t ( s u m b u f f e r i t e r a t o r ) ) . sum ( ) ;

}

// S o r t t h e sum a r r a y

A r r a y s . p a r a l l e l S o r t ( s u m a r r a y ) ;

System . o u t . p r i n t l n ( ” Get a l l i n d e x o f t h e communites done ! ” ) ;

// Get t h e a l l i n d e x o f t h e / n u m b e r o f c o m m u n i t i e s / l a r g e s t sum i n t h e a r r a y /∗f o r ( i n t s u m b u f f e r i t e r a t o r = 0 ; s u m b u f f e r i t e r a t o r < n u m b e r o f c o m m u n i t i e s ;

s u m b u f f e r i t e r a t o r ++){

i f ( ! ( m a x i n t . c o n t a i n s ( g e t I n d e x O f A l l ( s u m a r r a y [ s u m a r r a y . l e n g t h − s u m b u f f e r i t e r a t o r − 1 ] , s u m b u f f e r ) . g e t ( 0 ) ) ) ){

m a x i n t . a d d A l l ( g e t I n d e x O f A l l ( s u m a r r a y [ s u m a r r a y . l e n g t h − s u m b u f f e r i t e r a t o r − 1 ] , s u m b u f f e r ) ) ;

}

}∗/

System . o u t . p r i n t l n ( ” T e s t s u b j e c t done !∗ m a x i n t s i z e : ” + m a x i n t . s i z e ( ) ) ; System . o u t . p r i n t l n ( ” sum a r r l e n g t h : ” + s u m a r r a y . l e n g t h ) ;

i n t s u m b u f f e r i t e r a t o r = 0 ;

w h i l e ( ( s u m b u f f e r i t e r a t o r < s u m a r r a y . l e n g t h ) ){

i f ( ! ( m a x i n t . c o n t a i n s ( g e t I n d e x O f A l l ( s u m a r r a y [ s u m a r r a y . l e n g t h − s u m b u f f e r i t e r a t o r − 1 ] , s u m b u f f e r ) . g e t ( 0 ) ) ) ){

i f ( s u m a r r a y [ s u m a r r a y . l e n g t h − s u m b u f f e r i t e r a t o r − 1 ] ! = 0 ){ // System . o u t . p r i n t l n ( ”Sum a r r a y v a l u e added : ” + s u m a r r a y

[ s u m a r r a y . l e n g t h − s u m b u f f e r i t e r a t o r − 1 ] ) ; m a x i n t . a d d A l l ( g e t I n d e x O f A l l ( s u m a r r a y [ s u m a r r a y . l e n g t h −

s u m b u f f e r i t e r a t o r − 1 ] , s u m b u f f e r ) ) ; }

}

// System . o u t . p r i n t l n ( ”Sum b u f f : ” + s u m b u f f e r i t e r a t o r ) ; s u m b u f f e r i t e r a t o r ++;

}

System . o u t . p r i n t l n ( ” T e s t s u b j e c t done ! m a x i n t s i z e : ” + m a x i n t . s i z e ( ) ) ; // m a x i n t = l i m i t C o m m u n i t i e s ( m a x i n t , n u m b e r o f c o m m u n i t i e s ) ;

// System . o u t . p r i n t l n ( ” T e s t s u b j e c t done ! m a x i n t s i z e : ” + m a x i n t . s i z e ( ) ) ; f o r ( i n t s u m c o u n t e r = 0 ; s u m c o u n t e r < m a x i n t . s i z e ( ) ; s u m c o u n t e r++){

L e g i s l a t o r [ ] m a x l e g i s l a t o r s = new L e g i s l a t o r [ c l i q u e s i z e ] ; A r r a y L i s t<I n t e g e r> i n d e x e s = new A r r a y L i s t<I n t e g e r>() ; b o o l e a n h a s Z e r o = f a l s e ;

k e y a r r a y = k e y s . g e t ( m a x i n t . g e t ( s u m c o u n t e r ) ) ;

f o r ( i n t v e r t e x i t e r a t o r = 0 ; v e r t e x i t e r a t o r < c l i q u e s i z e ; v e r t e x i t e r a t o r ++){

System . o u t . p r i n t ( k e y a r r a y [ v e r t e x i t e r a t o r ] + ” ” ) ; i f ( k e y a r r a y [ v e r t e x i t e r a t o r ] == 0 ){

h a s Z e r o = t r u e ; }

}

System . o u t . p r i n t l n ( ” ” ) ;

f o r ( i n t v e r t e x i t e r a t o r = 0 ; v e r t e x i t e r a t o r < c l i q u e s i z e ; v e r t e x i t e r a t o r ++){

i f ( i n d e x e s . c o n t a i n s A l l ( g e t I n d e x O f A l l ( k e y a r r a y [ v e r t e x i t e r a t o r ] , i n t T o L i s t ( a d j m a t r i x 1 [ m a x i n t . g e t ( s u m c o u n t e r ) ] ) ) ) == f a l s e

){

i n d e x e s . a d d A l l ( g e t I n d e x O f A l l ( k e y a r r a y [ v e r t e x i t e r a t o r ] , i n t T o L i s t ( a d j m a t r i x 1 [ m a x i n t . g e t ( s u m c o u n t e r ) ] ) ) ) ;

// System . o u t . p r i n t ( a d j m a t r i x 1 [ s u m c o u n t e r ] [ v e r t e x i t e r a t o r ] ) ; }

}

i n d e x e s = l i m i t C o m m u n i t i e s ( i n d e x e s , c l i q u e s i z e ) ;

f o r ( i n t i n d e x i t e r a t o r = 0 ; i n d e x i t e r a t o r < c l i q u e s i z e ; i n d e x i t e r a t o r ++){

// System . o u t . p r i n t ( i n d e x e s . g e t ( i n d e x i t e r a t o r ) + ” ” ) ;

m a x l e g i s l a t o r s [ i n d e x i t e r a t o r ] = l e g i s l a t o r s . g e t ( i n d e x e s . g e t ( i n d e x i t e r a t o r ) ) ;

}

i f ( h a s Z e r o == f a l s e ){

f i n a l w e i g h t s . add ( s u m a r r a y [ s u m a r r a y . l e n g t h − s u m c o u n t e r −1]) ; r e s u l t s . add ( m a x l e g i s l a t o r s ) ;

}

System . o u t . p r i n t l n ( ” ” ) ;

// f o r ( i n t l e g i t e r = 0 ; l e g i t e r < r e s u l t s . g e t ( s u m c o u n t e r ) . l e n g t h ; l e g i t e r ++){

// System . o u t . p r i n t ( r e s u l t s . g e t ( s u m c o u n t e r ) [ l e g i t e r ] . getName ( ) +

” ” ) ; //}

}

r e t u r n r e s u l t s ; }

p u b l i c A r r a y L i s t<I n t e g e r> g e t F i n a l W e i g h t s ( ){ r e t u r n f i n a l w e i g h t s ;

}

p u b l i c A r r a y L i s t<I n t e g e r> g e t I n d e x O f A l l ( i n t i n t m a x , A r r a y L i s t<I n t e g e r> s u m b u f f e r ){ A r r a y L i s t<I n t e g e r> i n d e x e s = new A r r a y L i s t<I n t e g e r>() ;

f o r ( i n t b u f f e r i t e r a t o r = 0 ; b u f f e r i t e r a t o r < s u m b u f f e r . s i z e ( ) ; b u f f e r i t e r a t o r ++){

i f ( i n t m a x == s u m b u f f e r . g e t ( b u f f e r i t e r a t o r ) ){ i n d e x e s . add ( b u f f e r i t e r a t o r ) ;

} }

r e t u r n i n d e x e s ; }

p u b l i c A r r a y L i s t<I n t e g e r> i n t T o L i s t ( i n t [ ] i n t a r r ){

A r r a y L i s t<I n t e g e r> i n t l i s t = new A r r a y L i s t<I n t e g e r>() ; f o r ( i n t i t e r a t o r = 0 ; i t e r a t o r < i n t a r r . l e n g t h ; i t e r a t o r ++){

i n t l i s t . add ( i n t a r r [ i t e r a t o r ] ) ; }

r e t u r n i n t l i s t ; }

p u b l i c A r r a y L i s t<I n t e g e r> l i m i t C o m m u n i t i e s ( A r r a y L i s t<I n t e g e r> i n d e x l i s t , i n t n u m b e r o f c o m m u n i t i e s ){

f o r ( i n t t r i m i t e r a t o r = i n d e x l i s t . s i z e ( ) ; t r i m i t e r a t o r > n u m b e r o f c o m m u n i t i e s ; t r i m i t e r a t o r−−){

i n d e x l i s t . remove ( t r i m i t e r a t o r − 1 ) ; }

r e t u r n i n d e x l i s t ; }

}

MWCP Exact GPU.java

i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . c u C t x C r e a t e ; i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . c u C t x S y n c h r o n i z e ; i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . c u D e v i c e G e t ; i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . c u I n i t ;

i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . c u L a u n c h K e r n e l ; i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . cuMemAlloc ; i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . cuMemFree ; i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . cuMemcpyDtoH ; i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . cuMemcpyHtoD ; i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . c u M o d u l e G e t F u n c t i o n ; i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r . cuModuleLoad ; i m p o r t j c u d a . r u n t i m e . JCuda ;

i m p o r t j c u d a . d r i v e r .∗;

i m p o r t s t a t i c j c u d a . d r i v e r . C U d e v i c e a t t r i b u t e .∗; i m p o r t s t a t i c j c u d a . d r i v e r . J C u d a D r i v e r .∗; i m p o r t j a v a . i o . B y t e A r r a y O u t p u t S t r e a m ; i m p o r t j a v a . i o . F i l e ;

i m p o r t j a v a . i o . I O E x c e p t i o n ; i m p o r t j a v a . i o . I n p u t S t r e a m ; i m p o r t j a v a . math . B i g I n t e g e r ; i m p o r t j a v a . u t i l . A r r a y L i s t ; i m p o r t j a v a . u t i l . Comparator ; i m p o r t j a v a . u t i l . P r i o r i t y Q u e u e ;

i m p o r t j c u d a . P o i n t e r ; i m p o r t j c u d a . S i z e o f ;

i m p o r t j c u d a . d r i v e r . CUcontext ; i m p o r t j c u d a . d r i v e r . CUdevice ; i m p o r t j c u d a . d r i v e r . C U d e v i c e p t r ; i m p o r t j c u d a . d r i v e r . C U f u n c t i o n ; i m p o r t j c u d a . d r i v e r . CUmodule ; i m p o r t j c u d a . d r i v e r . J C u d a D r i v e r ;

p u b l i c c l a s s MWCP Exact GPU {

p r i v a t e s t a t i c i n t n u m b e r o f i n d i c e s ; p r i v a t e s t a t i c i n t [ ] [ ] a d j m a t r i x ; p r i v a t e s t a t i c i n t c l i q u e s i z e ; p r i v a t e s t a t i c i n t n u m o f c o m m u n i t i e s ;

p r i v a t e s t a t i c A r r a y L i s t<L e g i s l a t o r> l e g i s l a t o r s ;

s t a t i c A r r a y L i s t<I n t e g e r> o u t p u t I n d i c e s = new A r r a y L i s t<I n t e g e r>() ; Comparator<q u e u e E l e m e n t>com = new L e g i s l a t o r C o m p a r a t o r ( ) ;

P r i o r i t y Q u e u e<q u e u e E l e m e n t> q u e u e = new P r i o r i t y Q u e u e<q u e u e E l e m e n t>(com ) ; A r r a y L i s t<I n t e g e r> f i n a l w e i g h t s = new A r r a y L i s t<I n t e g e r>() ;

p u b l i c MWCP Exact GPU ( ){ }

p u b l i c MWCP Exact GPU ( A r r a y L i s t<L e g i s l a t o r> l e g i s l a t o r s , i n t [ ] [ ] a d j m a t r i x , i n t c l i q u e s i z e , i n t n u m o f c o m m u n i t i e s ){

t h i s . l e g i s l a t o r s = l e g i s l a t o r s ;

t h i s . n u m b e r o f i n d i c e s = n u m b e r o f i n d i c e s ;

t h i s . c l i q u e s i z e = c l i q u e s i z e ;

t h i s . n u m o f c o m m u n i t i e s = n u m o f c o m m u n i t i e s ; }

p u b l i c s t a t i c i n t [ ] s e t I n d e x A r r a y ( i n t n ){

i n t [ ] i n d e x a r r a y = new i n t [ n ] ; f o r ( i n t i t e r = 0 ; i t e r < n ; i t e r ++){

i n d e x a r r a y [ i t e r ] = i t e r ; }

r e t u r n i n d e x a r r a y ; }

p u b l i c s t a t i c i n t g e t I n d e x L e n ( ){ r e t u r n l e g i s l a t o r s . s i z e ( ) ; }

p u b l i c s t a t i c i n t g e t C l i q u e S i z e ( ){ r e t u r n c l i q u e s i z e ; }

p u b l i c s t a t i c i n t getCommNum ( ){ r e t u r n n u m o f c o m m u n i t i e s ; }

p u b l i c s t a t i c i n t computeSum ( i n t [ ] i n d i c e s ){ i n t t o t a l S u m = 0 ;

f o r ( i n t i t e r = 0 ; i t e r < i n d i c e s . l e n g t h − 1 ; i t e r ++){

t o t a l S u m += a d j m a t r i x [ i n d i c e s [ i t e r ] ] [ i n d i c e s [ i t e r + 1 ] ] ; }

r e t u r n t o t a l S u m ; }

p u b l i c s t a t i c i n t getNumOfGPUAvailable ( ) { J C u d a D r i v e r . s e t E x c e p t i o n s E n a b l e d ( t r u e ) ; c u I n i t ( 0 ) ;

// O b t a i n t h e number o f d e v i c e s i n t d e v i c e C o u n t A r r a y [ ] = { 0 };

c u D e v i c e G e t C o u n t ( d e v i c e C o u n t A r r a y ) ; i n t d e v i c e C o u n t = d e v i c e C o u n t A r r a y [ 0 ] ;

System . o u t . p r i n t l n ( ” Found ” + d e v i c e C o u n t + ” d e v i c e s . ” ) ; r e t u r n d e v i c e C o u n t ;

}

p u b l i c v o i d runGPUAlgorithm ( ) t h r o w s I O E x c e p t i o n {

// E n a b l e e x c e p t i o n s and o m i t a l l s u b s e q u e n t e r r o r c h e c k s J C u d a D r i v e r . s e t E x c e p t i o n s E n a b l e d ( t r u e ) ;

// I n i t i a l i z e t h e d r i v e r and c r e a t e a c o n t e x t f o r t h e f i r s t d e v i c e c u I n i t ( 0 ) ;

CUdevice d e v i c e = new CUdevice ( ) ; c u D e v i c e G e t ( d e v i c e , 0 ) ;

CUcontext c o n t e x t = new CUcontext ( ) ; c u C t x C r e a t e ( c o n t e x t , 0 , d e v i c e ) ;

// C r e a t e t h e PTX f i l e by c a l l i n g t h e NVCC // S t r i n g p t x F i l e N a m e = p r e p a r e P t x F i l e ( ” com . cu ” ) ;

b y t e p t x D a t a [ ] = t o B y t e A r r a y ( g e t C l a s s ( ) . g e t R e s o u r c e A s S t r e a m ( ” / com . p t x ” ) ) ; // S t r i n g p t x F i l e N a m e = p r e p a r e P t x F i l e ( ” c o m b i n a t i o n . cu ” ) ;

// Load t h e p t x f i l e

CUmodule module = new CUmodule ( ) ; cuModuleLoadData ( module , p t x D a t a ) ; // cuModuleLoad ( module , p t x F i l e N a m e ) ;

// O b t a i n a f u n c t i o n p o i n t e r t o t h e ” c o m b i n a t i o n ” a l g o r i t h m f u n c t i o n C U f u n c t i o n f u n c t i o n = new C U f u n c t i o n ( ) ;

c u M o d u l e G e t F u n c t i o n ( f u n c t i o n , module , ” c o m b i n a t i o n ” ) ; // A l l o c a t e t h e h o s t i n p u t d a t a

i n t [ ] i n d e x a r r a y = s e t I n d e x A r r a y ( g e t I n d e x L e n ( ) ) ; i n t n u m O f I n d i c e s = g e t I n d e x L e n ( ) ;

i n t c l i q u e S i z e = g e t C l i q u e S i z e ( ) ; i n t number comm = getCommNum ( ) ; i n t o u t p u t S i z e = 9 9 0 0 0 0 0 0 ;

i n t [ ] d a t a r e s = new i n t [ getCommNum ( ) ] ; System . o u t . p r i n t l n ( ”∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗” ) ;

System . o u t . p r i n t l n ( ” H o s t i n p u t i n d i c e s s i z e : ” + n u m O f I n d i c e s ) ; // System . o u t . p r i n t l n ( ” H o s t i n p u t i n d i c e s o f b a s e g e n e c l u s t e r s : ” +

i n d i c e s O f B a s e G e n e C l u s t e r s . l e n g t h ) ;

System . o u t . p r i n t l n ( ” H o s t o u t p u t s i z e : ” + o u t p u t S i z e ) ; System . o u t . p r i n t l n ( ”∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗” ) ;

// A l l o c a t e t h e d e v i c e i n p u t d a t a , and c o p y t h e h o s t i n p u t d a t a t o t h e d e v i c e

C U d e v i c e p t r d e v i n d i c e s = new C U d e v i c e p t r ( ) ; cuMemAlloc ( d e v i n d i c e s , n u m O f I n d i c e s ∗ S i z e o f . INT ) ;

cuMemcpyHtoD ( d e v i n d i c e s , P o i n t e r . t o ( i n d e x a r r a y ) , n u m O f I n d i c e s ∗ S i z e o f . INT ) ; C U d e v i c e p t r d e v r e s = new C U d e v i c e p t r ( ) ;

cuMemAlloc ( d e v r e s , c l i q u e S i z e ∗ S i z e o f . INT ) ;

cuMemcpyHtoD ( d e v r e s , P o i n t e r . t o ( d a t a r e s ) , c l i q u e S i z e ∗ S i z e o f . INT ) ; // A l l o c a t e d e v i c e o u t p u t memory

C U d e v i c e p t r d e v o u t p u t = new C U d e v i c e p t r ( ) ; cuMemAlloc ( d e v o u t p u t , o u t p u t S i z e ∗ S i z e o f . INT ) ;

// S e t up t h e k e r n e l p a r a m e t e r s : A p o i n t e r t o an a r r a y o f p o i n t e r s w h i c h p o i n t t o t h e a c t u a l v a l u e s

P o i n t e r k e r n e l P a r a m e t e r s = P o i n t e r . t o ( P o i n t e r . t o ( d e v i n d i c e s ) ,

P o i n t e r . t o ( new i n t [ ]{n u m O f I n d i c e s}) , P o i n t e r . t o ( new i n t [ ]{c l i q u e S i z e}) , P o i n t e r . t o ( d e v r e s ) ,

P o i n t e r . t o ( d e v o u t p u t ) ) ;

// C a l l t h e k e r n e l f u n c t i o n i n t b l o c k S i z e X = 1 ;

i n t g r i d S i z e X = 1 ; // i n t b l o c k S i z e X = 2 5 6 ;

// i n t g r i d S i z e X = ( i n t ) Math . c e i l ( ( d o u b l e ) numOfElements / b l o c k S i z e X ) ; c u L a u n c h K e r n e l ( f u n c t i o n ,

g r i d S i z e X , 1 , 1 , // G r i d d i m e n s i o n

b l o c k S i z e X , 1 , 1 , // B l o c k d i m e n s i o n

0 , n u l l , // S h a r e d memory s i z e and

s t r e a m

k e r n e l P a r a m e t e r s , n u l l // K e r n e l and e x t r a p a r a m e t e r s ) ;

c u C t x S y n c h r o n i z e ( ) ;

// A l l o c a t e h o s t o u t p u t memory and c o p y t h e d e v i c e o u t p u t t o t h e h o s t i n t [ ] o u t p u t = new i n t [ o u t p u t S i z e ] ;

cuMemcpyDtoH ( P o i n t e r . t o ( o u t p u t ) , d e v o u t p u t , o u t p u t S i z e ∗ S i z e o f . FLOAT) ; // P r i n t r e s u l t s

System . o u t . p r i n t l n ( ” R e s u l t s : ” ) ;

f o r ( i n t i = 0 ; i < o u t p u t . l e n g t h ; i ++) { i f ( o u t p u t [ i ] == 0 && o u t p u t [ i +1] == 0 ){

b r e a k ; }

i f ( i%c l i q u e S i z e == 0 ) {

// System . o u t . p r i n t l n ( ) ; }

o u t p u t I n d i c e s . add ( o u t p u t [ i ] ) ; // System . o u t . p r i n t ( o u t p u t [ i ] + ” ” ) ; }

// o u t p u t I n d i c e s = o u t p u t ; // C l e a n up

cuMemFree ( d e v i n d i c e s ) ; cuMemFree ( d e v o u t p u t ) ; cuMemFree ( d e v r e s ) ; }

p u b l i c A r r a y L i s t<L e g i s l a t o r [ ]> t h r o w R e s u l t s ( ){

// L e g i s l a t o r [ ] c l i q u e = new L e g i s l a t o r [ g e t C l i q u e S i z e ( ) ] ; A r r a y L i s t<L e g i s l a t o r [ ]> r e s u l t = new A r r a y L i s t<L e g i s l a t o r [ ]>( ) ; A r r a y L i s t<i n t [ ]> i n d e x a r r = new A r r a y L i s t<i n t [ ]>( ) ;

f o r ( i n t i t e r = 0 ; i t e r < o u t p u t I n d i c e s . s i z e ( ) ; i t e r+=g e t C l i q u e S i z e ( ) ){

i n t [ ] d a t a r e s = new i n t [ g e t C l i q u e S i z e ( ) ] ;

f o r ( i n t i t e r 2 = i t e r ; i t e r 2 < i t e r +g e t C l i q u e S i z e ( ) ; i t e r 2 ++){

d a t a r e s [ i t e r 2 − i t e r ] = o u t p u t I n d i c e s . g e t ( i t e r 2 ) ; // System . o u t . p r i n t ( o u t p u t I n d i c e s . g e t ( i t e r 2 ) + ” ” ) ;

}

i n d e x a r r . add ( d a t a r e s ) ;

// System . o u t . p r i n t l n ( i n d e x a r r . g e t ( i t e r / g e t C l i q u e S i z e ( ) ) [ 0 ] + ” ” + i n d e x a r r . g e t ( i t e r / g e t C l i q u e S i z e ( ) ) [ 1 ] ) ;

}

f o r ( i n t q u e u e I t e r = 0 ; q u e u e I t e r < i n d e x a r r . s i z e ( ) ; q u e u e I t e r ++){

q u e u e E l e m e n t dataQ = new q u e u e E l e m e n t ( i n d e x a r r . g e t ( q u e u e I t e r ) ) ; i n t c u r r s u m = dataQ . getSum ( ) ;

// System . o u t . p r i n t l n ( dataQ . g e t I n d e x ( ) [ 0 ] + ” ” + dataQ . g e t I n d e x ( ) [ 1 ] + ”∗”

+ c u r r s u m ) ;

/∗i f ( q u e u e . s i z e ( ) <getCommNum ( ) ){

q u e u e . add ( dataQ ) ; }e l s e{

i f ( dataQ . getSum ( ) > q u e u e . p e e k ( ) . getSum ( ) ){

q u e u e . remove ( ) ; q u e u e . add ( dataQ ) ; }

}∗/

i f ( dataQ . h a s Z e r o == f a l s e ){

q u e u e . add ( dataQ ) ; }

}

f o r ( q u e u e E l e m e n t q : q u e u e ){

// System . o u t . p r i n t l n ( q . g e t I n d e x ( ) [ 0 ] +” ”+q . g e t I n d e x ( ) [ 1 ] ) ; }

/∗f o r ( i n t i t e r = 0 ; i t e r < o u t p u t I n d i c e s . s i z e ( ) − 1 ; i t e r += g e t C l i q u e S i z e ( ) ){

i n t [ ] d a t a r e s = new i n t [ g e t C l i q u e S i z e ( ) ] ;

f o r ( i n t i t e r 2 = i t e r ; i t e r 2 < i t e r +g e t C l i q u e S i z e ( ) − 1 ; i t e r 2 ++){

d a t a r e s [ i t e r 2 − i t e r ] = o u t p u t I n d i c e s . g e t ( i t e r 2 ) ; System . o u t . p r i n t ( d a t a r e s [ i t e r 2 − i t e r ] + ” ” ) ; }∗/

/∗q u e u e E l e m e n t dataQ = new q u e u e E l e m e n t ( d a t a r e s 2 ) ; i n t c u r r s u m = dataQ . getSum ( ) ;

System . o u t . p r i n t l n ( ” C u r r e n t sum : ” + c u r r s u m + ” ” ) ; i f ( q u e u e . s i z e ( ) <getCommNum ( ) ){

q u e u e . add ( dataQ ) ; }e l s e{

i f ( dataQ . getSum ( ) > q u e u e . p e e k ( ) . getSum ( ) ){

System . o u t . p r i n t l n ( ” Head removed , new C o m b i n a t i o n added ” ) ; f o r ( i n t i t e r R = 0 ; i t e r R < q u e u e . e l e m e n t ( ) . g e t I n d e x ( ) .

l e n g t h ; i t e r R ++){

System . o u t . p r i n t ( q u e u e . e l e m e n t ( ) . g e t I n d e x ( ) [ i t e r R ] + ” ” ) ;

}

q u e u e . remove ( ) ; q u e u e . add ( dataQ ) ; }

}∗/

w h i l e ( q u e u e . isEmpty ( ) == f a l s e ){

L e g i s l a t o r [ ] l e g l i s t = new L e g i s l a t o r [ q u e u e . e l e m e n t ( ) . g e t I n d e x ( ) . l e n g t h ] ; f o r ( i n t i t e r R = 0 ; i t e r R < q u e u e . e l e m e n t ( ) . g e t I n d e x ( ) . l e n g t h ; i t e r R ++){

// System . o u t . p r i n t ( q u e u e . e l e m e n t ( ) . g e t I n d e x ( ) [ i t e r R ] + ” ” ) ; l e g l i s t [ i t e r R ] = l e g i s l a t o r s . g e t ( q u e u e . e l e m e n t ( ) . g e t I n d e x ( ) [ i t e r R

] ) ; }

f i n a l w e i g h t s . add ( q u e u e . e l e m e n t ( ) . getSum ( ) ) ; r e s u l t . add ( l e g l i s t ) ;

System . o u t . p r i n t l n ( ” ” ) ; q u e u e . remove ( ) ;

}

r e t u r n r e s u l t ; }

p u b l i c A r r a y L i s t<I n t e g e r> g e t F i n a l W e i g h t s ( ){ r e t u r n f i n a l w e i g h t s ;

}

p u b l i c i n t getSumOfCom ( i n t [ ] d a t a A r r ){ i n t t o t a l S u m = 0 ;

f o r ( i n t i t e r a t o r = 0 ; i t e r a t o r < d a t a A r r . l e n g t h − 1 ; i t e r a t o r ++){

t o t a l S u m += t h i s . a d j m a t r i x [ d a t a A r r [ i t e r a t o r ] ] [ d a t a A r r [ i t e r a t o r + 1 ] ] ; }

t o t a l S u m = t o t a l S u m + t h i s . a d j m a t r i x [ d a t a A r r [ 0 ] ] [ d a t a A r r [ d a t a A r r . l e n g t h − 1 ] ] ; r e t u r n t o t a l S u m ;

}

p u b l i c b o o l e a n h a s Z e r o A d j ( i n t [ ] d a t a A r r ){

f o r ( i n t i t e r a t o r = 0 ; i t e r a t o r < d a t a A r r . l e n g t h − 1 ; i t e r a t o r ++){

i f ( t h i s . a d j m a t r i x [ d a t a A r r [ i t e r a t o r ] ] [ d a t a A r r [ i t e r a t o r + 1 ] ] == 0 ){

r e t u r n t r u e ; }

}

r e t u r n f a l s e ; }

p u b l i c c l a s s L e g i s l a t o r C o m p a r a t o r i m p l e m e n t s Comparator<q u e u e E l e m e n t>{

p u b l i c i n t compare ( q u e u e E l e m e n t x , q u e u e E l e m e n t y ) { // TODO Auto−g e n e r a t e d method s t u b

r e t u r n I n t e g e r . compare ( x . getSum ( ) , y . getSum ( ) ) ;

// r e t u r n 0 ; }

}

c l a s s q u e u e E l e m e n t{

i n t [ ] i n d e x ; i n t sum ;

b o o l e a n h a s Z e r o ;

p u b l i c q u e u e E l e m e n t ( i n t [ ] i n d e x ){ t h i s . i n d e x = i n d e x ;

t h i s . sum = getSumOfCom ( i n d e x ) ; t h i s . h a s Z e r o = h a s Z e r o A d j ( i n d e x ) ; }

p u b l i c i n t [ ] g e t I n d e x ( ){ r e t u r n t h i s . i n d e x ; }

p u b l i c i n t getSum ( ){ r e t u r n t h i s . sum ; }

}

/∗∗

∗ The e x t e n s i o n o f t h e g i v e n f i l e name i s r e p l a c e d w i t h ” p t x ” .

∗ I f t h e f i l e w i t h t h e r e s u l t i n g name d o e s n o t e x i s t , i t i s

∗ c o m p i l e d f r o m t h e g i v e n f i l e u s i n g NVCC. The name o f t h e

∗ PTX f i l e i s r e t u r n e d .

∗ @param c u F i l e N a m e The name o f t h e . CU f i l e

∗ @ r e t u r n The name o f t h e PTX f i l e

∗ @throws I O E x c e p t i o n I f an I /O e r r o r o c c u r s

∗/

p r i v a t e S t r i n g p r e p a r e P t x F i l e ( S t r i n g c u F i l e N a m e ) t h r o w s I O E x c e p t i o n { i n t e n d I n d e x = c u F i l e N a m e . l a s t I n d e x O f ( ’ . ’ ) ;

i f ( e n d I n d e x == −1) {

e n d I n d e x = c u F i l e N a m e . l e n g t h ( )−1;

}

S t r i n g p t x F i l e N a m e = c u F i l e N a m e . s u b s t r i n g ( 0 , e n d I n d e x +1)+”p t x ” ; F i l e p t x F i l e = new F i l e ( p t x F i l e N a m e ) ;

i f ( p t x F i l e . e x i s t s ( ) ) { r e t u r n p t x F i l e N a m e ; }

F i l e c u F i l e = new F i l e ( c u F i l e N a m e ) ;

System . o u t . p r i n t l n ( c u F i l e . g e t A b s o l u t e P a t h ( ) ) ; i f ( ! c u F i l e . e x i s t s ( ) ) {

t h r o w new I O E x c e p t i o n ( ” I n p u t f i l e n o t f o u n d : ”+c u F i l e N a m e ) ; }

S t r i n g m o d e l S t r i n g = ”−m” + System . g e t P r o p e r t y ( ” s u n . a r c h . d a t a . model ” ) ;

S t r i n g command = ” n v c c ” + m o d e l S t r i n g + ” −p t x ” + c u F i l e . g e t P a t h ( ) + ”−o ” + p t x F i l e N a m e ;

System . o u t . p r i n t l n ( ” E x e c u t i n g\n”+command ) ;

P r o c e s s p r o c e s s = Runtime . g e t R u n t i m e ( ) . e x e c ( command ) ;

S t r i n g e r r o r M e s s a g e = new S t r i n g ( t o B y t e A r r a y ( p r o c e s s . g e t E r r o r S t r e a m ( ) ) ) ; S t r i n g o u t p u t M e s s a g e = new S t r i n g ( t o B y t e A r r a y ( p r o c e s s . g e t I n p u t S t r e a m ( ) ) ) ; i n t e x i t V a l u e = 0 ;

t r y {

e x i t V a l u e = p r o c e s s . w a i t F o r ( ) ; }

c a t c h ( I n t e r r u p t e d E x c e p t i o n e ) { Thread . c u r r e n t T h r e a d ( ) . i n t e r r u p t ( ) ; t h r o w new I O E x c e p t i o n (

” I n t e r r u p t e d w h i l e w a i t i n g f o r n v c c o u t p u t ” , e ) ; }

i f ( e x i t V a l u e != 0 ) {

System . o u t . p r i n t l n ( ” n v c c p r o c e s s e x i t V a l u e ”+ e x i t V a l u e ) ; System . o u t . p r i n t l n ( ” e r r o r M e s s a g e :\n”+ e r r o r M e s s a g e ) ; System . o u t . p r i n t l n ( ” o u t p u t M e s s a g e :\n”+o u t p u t M e s s a g e ) ; t h r o w new I O E x c e p t i o n (

” Could n o t c r e a t e . p t x f i l e : ”+ e r r o r M e s s a g e ) ; }

System . o u t . p r i n t l n ( ” F i n i s h e d c r e a t i n g PTX f i l e ” ) ; r e t u r n p t x F i l e N a m e ;

} /∗∗

∗ F u l l y r e a d s t h e g i v e n I n p u t S t r e a m and r e t u r n s i t a s a b y t e a r r a y

∗ @param i n p u t S t r e a m The i n p u t s t r e a m t o r e a d

∗ @ r e t u r n The b y t e a r r a y c o n t a i n i n g t h e d a t a f r o m t h e i n p u t s t r e a m

∗/

p r i v a t e s t a t i c b y t e [ ] t o B y t e A r r a y ( I n p u t S t r e a m i n p u t S t r e a m ) t h r o w s I O E x c e p t i o n { B y t e A r r a y O u t p u t S t r e a m b a o s = new B y t e A r r a y O u t p u t S t r e a m ( ) ;

b y t e b u f f e r [ ] = new b y t e [ 8 1 9 2 ] ; w h i l e ( t r u e ) {

i n t r e a d = i n p u t S t r e a m . r e a d ( b u f f e r ) ; i f ( r e a d ==−1)

{

b r e a k ; }

b a o s . w r i t e ( b u f f e r , 0 , r e a d ) ; }

b a o s . w r i t e ( 0 ) ;

r e t u r n b a o s . t o B y t e A r r a y ( ) ; }

}

PriorityExact.java

i m p o r t j a v a . u t i l . A r r a y L i s t ; i m p o r t j a v a . u t i l . Comparator ; i m p o r t j a v a . u t i l . P r i o r i t y Q u e u e ; p u b l i c c l a s s P r i o r i t y E x a c t {

Comparator<q u e u e E l e m e n t>com = new L e g i s l a t o r C o m p a r a t o r ( ) ; i n t c o u n t e r = 0 ;

P r i o r i t y Q u e u e<q u e u e E l e m e n t> q u e u e = new P r i o r i t y Q u e u e<q u e u e E l e m e n t>(com ) ; A r r a y L i s t<I n t e g e r> f i n a l w e i g h t s = new A r r a y L i s t<I n t e g e r>() ;

// A r r a y L i s t<q u e u e E l e m e n t> t e s t = new A r r a y L i s t<q u e u e E l e m e n t>() ; p r i v a t e i n t [ ] [ ] a d j m a t r i x ;

p u b l i c P r i o r i t y E x a c t ( i n t [ ] [ ] a d j m a t r i x , i n t n u m b e r o f c o m m u n i t i e s ){ t h i s . a d j m a t r i x = a d j m a t r i x ;

// q u e u e . c l e a r ( ) ;

// t h i s . q u e u e = new P r i o r i t y Q u e u e<q u e u e E l e m e n t>(com ) ; // t h i s . t e s t = new A r r a y L i s t<q u e u e E l e m e n t>() ;

}

p u b l i c A r r a y L i s t<L e g i s l a t o r [ ]> e x a c t a l g o r i t h m ( A r r a y L i s t<L e g i s l a t o r> l e g i s l a t o r s , i n t [ ] [ ] a d j m a t r i x 1 , i n t c l i q u e s i z e , i n t n u m b e r o f c o m m u n i t i e s ){

A r r a y L i s t<L e g i s l a t o r [ ]> r e s u l t s = new A r r a y L i s t<L e g i s l a t o r [ ]>( ) ;

System . o u t . p r i n t l n ( ” M a t r i x dim : ” + a d j m a t r i x . l e n g t h + ” by ” + a d j m a t r i x [ 1 ] . l e n g t h ) ;

i n t [ ] d a t a r e s = new i n t [ c l i q u e s i z e ] ; i n t [ ] t e s t t = {1 , 2 , 3 , 4};

q u e u e E l e m e n t t e s t e r = new q u e u e E l e m e n t ( t e s t t ) ;

p e r f o r m C o m b i n a t i o n ( l e g i s l a t o r s , d a t a r e s , 0 , l e g i s l a t o r s . s i z e ( ) − 1 , 0 , c l i q u e s i z e , n u m b e r o f c o m m u n i t i e s ) ;

System . o u t . p r i n t l n ( ” Queue s i z e : ” + q u e u e . s i z e ( ) ) ; System . o u t . p r i n t l n ( ” Queue e n t r i e s : ” ) ;

w h i l e ( q u e u e . isEmpty ( ) == f a l s e ){

L e g i s l a t o r [ ] l e g l i s t = new L e g i s l a t o r [ q u e u e . e l e m e n t ( ) . g e t I n d e x ( ) . l e n g t h ] ; f o r ( i n t i t e r R = 0 ; i t e r R < q u e u e . e l e m e n t ( ) . g e t I n d e x ( ) . l e n g t h ; i t e r R ++){

// System . o u t . p r i n t ( q u e u e . e l e m e n t ( ) . g e t I n d e x ( ) [ i t e r R ] + ” ” ) ; l e g l i s t [ i t e r R ] = l e g i s l a t o r s . g e t ( q u e u e . e l e m e n t ( ) . g e t I n d e x ( ) [ i t e r R

] ) ; }

r e s u l t s . add ( l e g l i s t ) ;

f i n a l w e i g h t s . add ( q u e u e . e l e m e n t ( ) . getSum ( ) ) ; System . o u t . p r i n t l n ( ” ” ) ;

q u e u e . remove ( ) ; }

r e t u r n r e s u l t s ; }

/∗

∗/

p u b l i c A r r a y L i s t<I n t e g e r> g e t F i n a l W e i g h t s ( ){ r e t u r n f i n a l w e i g h t s ;

}

p u b l i c v o i d p e r f o r m C o m b i n a t i o n ( A r r a y L i s t<L e g i s l a t o r> l e g i s l a t o r s , i n t [ ] d a t a r e s , i n t s t a r t i n d e x , i n t e n d I n d e x , i n t i n d e x , i n t c l i q u e s i z e , i n t num com ){

i f ( i n d e x == c l i q u e s i z e ){ c o u n t e r ++;

q u e u e E l e m e n t dataQ = new q u e u e E l e m e n t ( d a t a r e s ) ;

System . o u t . p r i n t l n ( ” C o m b i n a t i o n ” + c o u n t e r + ” s o l v e d ! ” ) ; i n t c u r r s u m = dataQ . getSum ( ) ;

System . o u t . p r i n t l n ( ” C u r r e n t sum : ” + c u r r s u m + ” ” ) ; /∗i f ( q u e u e . s i z e ( ) < num com ){

q u e u e . add ( dataQ ) ; }e l s e{

i f ( dataQ . getSum ( ) > q u e u e . p e e k ( ) . getSum ( ) ){

System . o u t . p r i n t l n ( ” Head removed , new C o m b i n a t i o n added ” ) ; q u e u e . remove ( ) ;

q u e u e . add ( dataQ ) ; }

}∗/

i f ( dataQ . h a s Z e r o == f a l s e ){

q u e u e . add ( dataQ ) ; }

r e t u r n ; }

f o r ( i n t c u r r i n d e x = s t a r t i n d e x ; ( ( c u r r i n d e x <= e n d I n d e x ) && ( ( e n d I n d e x − c u r r i n d e x + 1 ) >= ( c l i q u e s i z e − i n d e x ) ) ) ; c u r r i n d e x ++){

i n t [ ] d a t a r e s 2 = new i n t [ c l i q u e s i z e ] ;

f o r ( i n t d a t a I t e r = 0 ; d a t a I t e r < d a t a r e s 2 . l e n g t h ; d a t a I t e r ++){

d a t a r e s 2 [ d a t a I t e r ] = d a t a r e s [ d a t a I t e r ] ; }

d a t a r e s 2 [ i n d e x ] = l e g i s l a t o r s . i n d e x O f ( l e g i s l a t o r s . g e t ( c u r r i n d e x ) ) ; p e r f o r m C o m b i n a t i o n ( l e g i s l a t o r s , d a t a r e s 2 , c u r r i n d e x + 1 , e n d I n d e x , i n d e x

+1 , c l i q u e s i z e , num com ) ; }

}

p u b l i c i n t getSumOfCom ( i n t [ ] d a t a A r r ){ i n t t o t a l S u m = 0 ;

f o r ( i n t i t e r a t o r = 0 ; i t e r a t o r < d a t a A r r . l e n g t h − 1 ; i t e r a t o r ++){

t o t a l S u m += t h i s . a d j m a t r i x [ d a t a A r r [ i t e r a t o r ] ] [ d a t a A r r [ i t e r a t o r + 1 ] ] ; }

r e t u r n t o t a l S u m ; }

p u b l i c b o o l e a n h a s Z e r o A d j ( i n t [ ] d a t a A r r ){

f o r ( i n t i t e r a t o r = 0 ; i t e r a t o r < d a t a A r r . l e n g t h − 1 ; i t e r a t o r ++){

i f ( t h i s . a d j m a t r i x [ d a t a A r r [ i t e r a t o r ] ] [ d a t a A r r [ i t e r a t o r + 1 ] ] == 0 ){

r e t u r n t r u e ; }

}

r e t u r n f a l s e ; }

p u b l i c c l a s s L e g i s l a t o r C o m p a r a t o r i m p l e m e n t s Comparator<q u e u e E l e m e n t>{

p u b l i c i n t compare ( q u e u e E l e m e n t x , q u e u e E l e m e n t y ) { // TODO Auto−g e n e r a t e d method s t u b

r e t u r n I n t e g e r . compare ( x . getSum ( ) , y . getSum ( ) ) ; // r e t u r n 0 ;

}

}

c l a s s q u e u e E l e m e n t{

i n t [ ] i n d e x ; i n t sum ;

b o o l e a n h a s Z e r o ;

p u b l i c q u e u e E l e m e n t ( i n t [ ] i n d e x ){ t h i s . i n d e x = i n d e x ;

t h i s . sum = getSumOfCom ( i n d e x ) ; t h i s . h a s Z e r o = h a s Z e r o A d j ( i n d e x ) ; }

p u b l i c i n t [ ] g e t I n d e x ( ){ r e t u r n t h i s . i n d e x ; }

p u b l i c i n t getSum ( ){ r e t u r n t h i s . sum ; }

}

}

R Integration RSERVE.java

i m p o r t j a v a . i o . I O E x c e p t i o n ; i m p o r t j a v a . u t i l . A r r a y L i s t ; i m p o r t j a v a . u t i l . A r r a y s ; i m p o r t j a v a . u t i l . C o l l e c t i o n s ; i m p o r t j a v a . u t i l . L i s t ;

i m p o r t j a v a . u t i l . s t r e a m . I n t S t r e a m ; i m p o r t o r g . r o s u d a . REngine .∗; i m p o r t o r g . r o s u d a . REngine . R s e r v e .∗; p u b l i c c l a s s R I n t e g r a t i o n R S E R V E {

A r r a y L i s t<L e g i s l a t o r> t o T h r o w L e g i s l a t o r = new A r r a y L i s t<L e g i s l a t o r>() ; A r r a y L i s t<I n t e g e r> r e s u l t w e i g h t s = new A r r a y L i s t<I n t e g e r>() ;

i n t [ ] [ ] t o T h r o w a d j ;

i n t c l i q u e s i z e , n u m b e r o f c o m m u n i t i e s ; S t r i n g [ ] f e a t u r e L i s t ;

S t r i n g f i l e P a t h ;

A r r a y L i s t<L e g i s l a t o r [ ]> toThrow community = new A r r a y L i s t<L e g i s l a t o r [ ]>( ) ; A r r a y L i s t<L e g i s l a t o r> m a t r i x L = new A r r a y L i s t<L e g i s l a t o r>() ;

R C o n n e c t i o n c ; REXP e v a l f i l e ;

i n t [ ] d e g r e e c e n t r a l i t y ; i n t [ ] d e g r e e W c e n t r a l i t y ; d o u b l e [ ] c l o s e n e s s c e n t r a l i t y ; d o u b l e [ ] b e t w e e n n e s s c e n t r a l i t y ; i n t n u m b e r o f d e v i c e s ;

p u b l i c R I n t e g r a t i o n R S E R V E ( ) t h r o w s R s e r v e E x c e p t i o n , REXPMismatchException{

c = new R C o n n e c t i o n ( ) ; }

p u b l i c v o i d r e x e c u t e C o n n e c t i o n ( S t r i n g f i l e P a t h ) t h r o w s R s e r v e E x c e p t i o n , REXPMismatchException{

t r y {

// make a new l o c a l c o n n e c t i o n on d e f a u l t p o r t ( 6 3 1 1 ) i n t d e l i m i t = f i l e P a t h . l a s t I n d e x O f ( ” . ” ) ;

REXP x0 = c . e v a l ( ” l i b r a r y ( ’ x l s x ’ ) ” ) ; REXP x i g r a p h = c . e v a l ( ” l i b r a r y ( i g r a p h ) ” ) ;

i f ( f i l e P a t h . s u b s t r i n g ( d e l i m i t , f i l e P a t h . l e n g t h ( ) ) . e q u a l s ( ” . x l s x ” ) ){

e v a l f i l e = c . e v a l ( ” d f <−r e a d . x l s x ( ’ ” + f i l e P a t h + ” ’ , sheetName = ’ S h e e t 1 ’ , h e a d e r = TRUE) ” ) ;

}e l s e i f ( f i l e P a t h . s u b s t r i n g ( d e l i m i t , f i l e P a t h . l e n g t h ( ) ) . e q u a l s ( ” . x l s ” ) ){

e v a l f i l e = c . e v a l ( ” d f <−r e a d . x l s ( ’ ” + f i l e P a t h + ” ’ , s h e e t = ’ S h e e t 1 ’ ” ) ; }e l s e i f ( f i l e P a t h . s u b s t r i n g ( d e l i m i t , f i l e P a t h . l e n g t h ( ) ) . e q u a l s ( ” . c s v ” ) ){

e v a l f i l e = c . e v a l ( ” d f <−r e a d . c s v ( ’ ” + f i l e P a t h + ” ’ , h e a d e r = TRUE, s e p = ’ , ’ ) ” )

; }

REXP e x p n r o w = c . e v a l ( ” nrow ( d f ) ” ) ; REXP e x p n c o l = c . e v a l ( ” n c o l ( d f ) ” ) ; REXP e x p h e a d e r s = c . e v a l ( ” c o l n a m e s ( d f ) ” ) ;

f e a t u r e L i s t = e x p h e a d e r s . a s S t r i n g s ( ) ; f o r ( S t r i n g h e a d e r : f e a t u r e L i s t ){

System . o u t . p r i n t l n ( h e a d e r ) ; }

i n t nrow = e x p n r o w . a s I n t e g e r ( ) ; i n t n c o l = e x p n c o l . a s I n t e g e r ( ) ;

// P a r s e t h e S p r e a d s h e e t f i l e i n t o an A r r a y L i s t o f L e g i s l a t o r s f o r ( i n t i n d e x r o w = 1 ; i n d e x r o w <= nrow ; i n d e x r o w ++){

L e g i s l a t o r l e g i s l a t o r = new L e g i s l a t o r ( ) ;

A r r a y L i s t<S t r i n g> f e a t u r e s = new A r r a y L i s t<S t r i n g>() ; f o r ( i n t i n d e x c o l = 1 ; i n d e x c o l <= n c o l ; i n d e x c o l ++){

REXP e x p e l e m e n t = c . e v a l ( ” d f [ ” + i n d e x r o w + ” , ” + i n d e x c o l + ” ] ” ) ; i f ( i n d e x c o l == 1 ){

l e g i s l a t o r . setName ( e x p e l e m e n t . a s S t r i n g ( ) ) ; }

e l s e{

f e a t u r e s . add ( e x p e l e m e n t . a s S t r i n g ( ) ) ; }

}

l e g i s l a t o r . s e t F e a t u r e ( f e a t u r e s ) ; m a t r i x L . add ( l e g i s l a t o r ) ; }

t o T h r o w L e g i s l a t o r = m a t r i x L ; } c a t c h ( R E n g i n e E x c e p t i o n e ) {

e . p r i n t S t a c k T r a c e ( ) ; }

}

p u b l i c v o i d r e x e c u t e ( S t r i n g Algo , i n t [ ] f e a t u r e c o l u m n ) t h r o w s R s e r v e E x c e p t i o n , REXPMismatchException{

G r a p h C o n s t r u c t i o n g = new G r a p h C o n s t r u c t i o n ( ) ; MWCP Approx Algorithm m = new MWCP Approx Algorithm ( ) ; MWCP Exact GPU egpu = new MWCP Exact GPU ( ) ;

P r i o r i t y E x a c t e ;

A r r a y L i s t<I n t e g e r> f e a t u r e c o l = new A r r a y L i s t<I n t e g e r>() ; f o r ( i n t i : f e a t u r e c o l u m n ){

f e a t u r e c o l . add ( i ) ; }

i n t [ ] [ ] a d j m a t r i x ;

a d j m a t r i x = g . c o n s t r u c t a d j a c e n c y m a t r i x c h o s e n ( m a t r i x L , f e a t u r e c o l ) ; t o T h r o w a d j = a d j m a t r i x ;

// g . p r i n t A d j ( a d j m a t r i x ) ;

System . o u t . p r i n t l n ( ” Number o f c o m m u n i t i e s ” + n u m b e r o f c o m m u n i t i e s ) ; System . o u t . p r i n t l n ( ” A l g o r i t h m Chosen : ” + A l g o ) ;

egpu = new MWCP Exact GPU ( m a t r i x L , a d j m a t r i x , c l i q u e s i z e , n u m b e r o f c o m m u n i t i e s ) ; i f ( A l g o . e q u a l s ( ” A p p r o x i m a t e A l g o r i t h m ” ) ){

toThrow community = m. a p p r o x a l g o r i t h m ( m a t r i x L , a d j m a t r i x , c l i q u e s i z e ) ; r e s u l t w e i g h t s = m. g e t F i n a l W e i g h t s ( ) ;

}e l s e i f ( A l g o . e q u a l s ( ” E x a c t A l g o r i t h m (GPU) ” ) ){ t r y {

egpu . runGPUAlgorithm ( ) ;

toThrow community = egpu . t h r o w R e s u l t s ( ) ; C o l l e c t i o n s . r e v e r s e ( toThrow community ) ; r e s u l t w e i g h t s = egpu . g e t F i n a l W e i g h t s ( ) ; C o l l e c t i o n s . r e v e r s e ( r e s u l t w e i g h t s ) ; } c a t c h ( I O E x c e p t i o n e 1 ) {

// TODO Auto−g e n e r a t e d c a t c h b l o c k e 1 . p r i n t S t a c k T r a c e ( ) ;

}

}e l s e i f ( A l g o . e q u a l s ( ” E x a c t A l g o r i t h m (CPU) ” ) ){

e = new P r i o r i t y E x a c t ( a d j m a t r i x , n u m b e r o f c o m m u n i t i e s ) ;

toThrow community = e . e x a c t a l g o r i t h m ( m a t r i x L , a d j m a t r i x , c l i q u e s i z e , n u m b e r o f c o m m u n i t i e s ) ;

C o l l e c t i o n s . r e v e r s e ( toThrow community ) ; r e s u l t w e i g h t s = ( e . g e t F i n a l W e i g h t s ( ) ) ; C o l l e c t i o n s . r e v e r s e ( r e s u l t w e i g h t s ) ; }

REXP e x p n a m e g r a p h = c . e v a l ( ” g <− g r a p h ( c (”+ g . g r a p h e x p ( a d j m a t r i x ) +”) , n = ” + a d j m a t r i x [ 0 ] . l e n g t h+ ” , d i r e c t e d = F ) ” ) ;

REXP e x p d e g r e e = c . e v a l ( ” c e n t r d e g r e e ( g , mode = ’ a l l ’ , n o r m a l i z e d = T) $ r e s ” ) ; REXP e x p c l o s e n e s s = c . e v a l ( ” c e n t r c l o ( g , mode = ’ a l l ’ , n o r m a l i z e d = T) $ r e s ” ) ; REXP e x p b e t w e e n n e s s = c . e v a l ( ” c e n t r b e t w ( g , d i r e c t e d = F , n o r m a l i z e d = T) $ r e s ” ) ;

d e g r e e c e n t r a l i t y = e x p d e g r e e . a s I n t e g e r s ( ) ;

d e g r e e W c e n t r a l i t y = c o m p u t e W e i g h t e d C e n t r a l i t y ( a d j m a t r i x ) ; c l o s e n e s s c e n t r a l i t y = e x p c l o s e n e s s . a s D o u b l e s ( ) ;

b e t w e e n n e s s c e n t r a l i t y = e x p b e t w e e n n e s s . a s D o u b l e s ( ) ;

}

p u b l i c A r r a y L i s t<I n t e g e r> g e t R e s u l t W e i g h t s ( ){

r e t u r n r e s u l t w e i g h t s ; }

p u b l i c i n t [ ] c o m p u t e W e i g h t e d C e n t r a l i t y ( i n t [ ] [ ] t e m p a d j ){

i n t [ ] degreeW = new i n t [ t e m p a d j . l e n g t h ] ;

f o r ( i n t i t e r = 0 ; i t e r < t e m p a d j . l e n g t h ; i t e r ++){

degreeW [ i t e r ] = I n t S t r e a m . o f ( t e m p a d j [ i t e r ] ) . sum ( ) ; }

r e t u r n degreeW ; }

p u b l i c A r r a y L i s t<L e g i s l a t o r> g e t L e g i s l a t o r s ( ){ r e t u r n t o T h r o w L e g i s l a t o r ;

}

p u b l i c i n t [ ] [ ] g e t A d j ( ){ r e t u r n t o T h r o w a d j ; }

p u b l i c A r r a y L i s t<I n t e g e r> a d d I n t T o L i s t ( S t r i n g [ ] t o I n t ){

A r r a y L i s t<I n t e g e r> f e a t u r e I n d e x = new A r r a y L i s t<I n t e g e r>() ; f o r ( S t r i n g s : t o I n t ){

f e a t u r e I n d e x . add ( I n t e g e r . p a r s e I n t ( s ) ) ; }

r e t u r n f e a t u r e I n d e x ; }

p u b l i c S t r i n g [ ] g e t F e a t u r e L i s t ( ){

r e t u r n A r r a y s . copyOfRange ( f e a t u r e L i s t , 1 , f e a t u r e L i s t . l e n g t h ) ; }

p u b l i c v o i d setNumberOfCommunities ( i n t communityNumber ){ t h i s . n u m b e r o f c o m m u n i t i e s = communityNumber ; }

p u b l i c i n t g e t C l i q u e S i z e ( ){

Dokumen terkait