1 | |
---|
2 | package jung; |
---|
3 | |
---|
4 | import clustering.Edge; |
---|
5 | import clustering.LocalSpectral; |
---|
6 | import clustering.VertexScore; |
---|
7 | import clustering.VertexString; |
---|
8 | import data.GraphBuilder; |
---|
9 | import edu.uci.ics.jung.algorithms.scoring.PageRank; |
---|
10 | import edu.uci.ics.jung.graph.AbstractGraph; |
---|
11 | import edu.uci.ics.jung.graph.Graph; |
---|
12 | import edu.uci.ics.jung.graph.SparseGraph; |
---|
13 | import java.awt.Paint; |
---|
14 | import java.util.ArrayList; |
---|
15 | import java.util.Collection; |
---|
16 | import java.util.List; |
---|
17 | import view.VertexPaintTransformer; |
---|
18 | import view.Viewer; |
---|
19 | |
---|
20 | public 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 | } |
---|