source: branches/localSpectral/src/jung/Main.java @ 33

Last change on this file since 33 was 32, checked in by toshi, 14 years ago
File size: 2.3 KB
Line 
1
2package jung;
3
4import clustering.Edge;
5import clustering.LocalSpectral;
6import clustering.VertexScore;
7import clustering.VertexString;
8import data.GraphBuilder;
9import edu.uci.ics.jung.algorithms.scoring.PageRank;
10import edu.uci.ics.jung.graph.AbstractGraph;
11import edu.uci.ics.jung.graph.Graph;
12import edu.uci.ics.jung.graph.SparseGraph;
13import java.awt.Paint;
14import java.util.ArrayList;
15import java.util.Collection;
16import java.util.List;
17import view.VertexPaintTransformer;
18import view.Viewer;
19
20public class Main {
21
22    public static void main(String[] args) {
23       GraphBuilder builder = new GraphBuilder();
24       builder.buildGraphFromARFF("/home/luke/Desktop/reteUtentiMikeHidden.arff", 1000);
25       //builder.buildGraphFromARFF("/home/luke/Desktop/reteSemplice.txt", 10000);
26       Graph<String, Edge<String>> graph = builder.getGraph();
27
28       LocalSpectral<String,Edge<String>> clusterer = new LocalSpectral(graph);
29       List<VertexScore<String>> global_ranking = clusterer.getGlobalRank();
30
31       System.out.println("GLOBAL RANKING");
32       for(VertexScore<String> v : global_ranking)
33           System.out.println(v.toString());
34       
35       Viewer viewGraph = new Viewer(graph);
36       viewGraph.viewGraphRank(global_ranking,null);
37       //viewGraph.viewGraph(null);
38
39       
40       for(VertexScore<String> v : global_ranking){
41           Long stoptime = 5000L; 
42           try {
43                Thread.sleep(stoptime);
44            } catch (InterruptedException e) {}
45           List<String> cut = clusterer.clusterPageRankPriors(v.getVertex(),6);
46           Graph<String,Edge<String>> cut_graph = new SparseGraph<String, Edge<String>>();
47           for(String vertex : cut){
48               Collection<Edge<String>> out_edges = graph.getOutEdges(vertex);
49               for(Edge<String> edge : out_edges){
50                   String out_node = edge.getVertex2();
51                   if (cut.contains(out_node)){
52                       cut_graph.addEdge(edge, edge.getVertex1(),edge.getVertex2());
53                   }
54               }
55           }
56           viewGraph.setGraph(cut_graph);
57           viewGraph.viewGraph(null);
58           try {
59                Thread.sleep(stoptime);
60           } catch (InterruptedException e) {}
61           viewGraph.setGraph(graph);
62           viewGraph.viewGraphRank(global_ranking, null);
63       }
64       
65
66    }
67
68
69}
Note: See TracBrowser for help on using the repository browser.