Changeset 32 for branches/localSpectral/src/jung
- Timestamp:
- Oct 21, 2010, 9:47:43 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/localSpectral/src/jung/Main.java
r27 r32 1 /*2 * To change this template, choose Tools | Templates3 * and open the template in the editor.4 */5 1 6 2 package jung; 7 3 4 import clustering.Edge; 8 5 import clustering.LocalSpectral; 9 6 import clustering.VertexScore; 7 import clustering.VertexString; 10 8 import data.GraphBuilder; 11 9 import edu.uci.ics.jung.algorithms.scoring.PageRank; 10 import edu.uci.ics.jung.graph.AbstractGraph; 12 11 import edu.uci.ics.jung.graph.Graph; 13 12 import edu.uci.ics.jung.graph.SparseGraph; … … 23 22 public static void main(String[] args) { 24 23 GraphBuilder builder = new GraphBuilder(); 25 builder.buildGraphFromARFF("/home/luke/Desktop/rete Semplice.txt", 6000);26 Graph<String, Integer> graph = builder.getGraph();27 Viewer viewGraph = new Viewer(graph);28 viewGraph.viewGraph(null); 29 LocalSpectral<String, Integer> clusterer = new LocalSpectral(graph);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); 30 29 List<VertexScore<String>> global_ranking = clusterer.getGlobalRank(); 30 31 31 System.out.println("GLOBAL RANKING"); 32 32 for(VertexScore<String> v : global_ranking) 33 System.out.println("VERTEX: "+v + " RANK "+v.getScore()); 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 34 40 for(VertexScore<String> v : global_ranking){ 35 41 Long stoptime = 5000L; … … 38 44 } catch (InterruptedException e) {} 39 45 List<String> cut = clusterer.clusterPageRankPriors(v.getVertex(),6); 40 viewGraph.viewGraph(cut); 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); 41 63 } 64 42 65 43 66 }
Note: See TracChangeset
for help on using the changeset viewer.