Changeset 32 for branches/localSpectral
- Timestamp:
- Oct 21, 2010, 9:47:43 PM (14 years ago)
- Location:
- branches/localSpectral
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/localSpectral/nbproject/private/private.properties
r27 r32 1 1 compile.on.save=true 2 do.depend=false 3 do.jar=true 4 javac.debug=true 5 javadoc.preview=true 2 6 user.properties.file=/home/luke/.netbeans/6.9/build.properties -
branches/localSpectral/nbproject/project.properties
r27 r32 1 1 annotation.processing.enabled=true 2 2 annotation.processing.enabled.in.editor=false 3 annotation.processing.processor.options=4 annotation.processing.processors.list=5 3 annotation.processing.run.all.processors=true 6 4 annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 5 application.title=Jung 6 application.vendor=luke 7 7 build.classes.dir=${build.dir}/classes 8 8 build.classes.excludes=**/*.java,**/*.form … … 25 25 dist.jar=${dist.dir}/Jung.jar 26 26 dist.javadoc.dir=${dist.dir}/javadoc 27 endorsed.classpath= 27 28 excludes= 28 29 file.reference.collections-generic-4.01.jar=/home/luke/Desktop/jung2-2_0_1/collections-generic-4.01.jar … … 78 79 # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value 79 80 # or test-sys-prop.name=value to set system properties for unit tests): 80 run.jvmargs= 81 run.jvmargs=-Xms1G 81 82 run.test.classpath=\ 82 83 ${javac.test.classpath}:\ -
branches/localSpectral/src/clustering/LocalSpectral.java
r27 r32 85 85 86 86 Collections.sort(vertexsScore,new VertexScoreComparator()); 87 88 double sum=0; 89 for(VertexScore<V> v : vertexsScore){ 90 System.out.println(v.getVertex().toString()+ " " + v.getScore()); 91 sum+=v.getScore(); 92 } 93 System.out.println("SUM SCORES: "+sum); 87 88 System.out.println("\n\nClustering with prior seed: "+seed.toString()); 94 89 95 90 int volume_graph = 2 * graph.getEdgeCount(); 96 System.out.println("GRAPH VOLUME: " + volume_graph);97 91 double max_volume = (volume_graph / 3) * 2; 98 92 double min_conductance_subset=100; … … 101 95 int subsets_count = vertexsScore.size(); 102 96 for(int i=0; i<subsets_count; i++){ 103 System.out.println("i="+i);104 97 int volume_subset = 0; 105 98 ArrayList<V> subset = new ArrayList<V>(); … … 127 120 } 128 121 } 129 System.out.println("CONDUCTANCE: "+conductance + " minvolume: "+minvolume + " edge_boundary: "+edge_boundary);122 //System.out.println("CONDUCTANCE: "+conductance + " minvolume: "+minvolume + " edge_boundary: "+edge_boundary); 130 123 } 131 124 132 125 } 133 System.out.println("MIN CONDUCTANCE: "+min_conductance_subset + " INDEX "+min_conductance_index);126 System.out.println("MIN CONDUCTANCE: "+min_conductance_subset); 134 127 128 System.out.println("CLUSTER: "); 135 129 List<V> cluster = new ArrayList<V>(); 136 130 for(int i=0; i< min_conductance_index; i++) 137 131 cluster.add(vertexsScore.get(i).getVertex()); 132 133 for(V node : cluster) 134 System.out.println(node.toString()); 138 135 139 136 return cluster; -
branches/localSpectral/src/data/GraphBuilder.java
r27 r32 2 2 package data; 3 3 4 import clustering.Edge; 5 import clustering.VertexString; 4 6 import edu.uci.ics.jung.graph.Graph; 5 7 import edu.uci.ics.jung.graph.SparseGraph; … … 16 18 17 19 18 public class GraphBuilder <V,E>{20 public class GraphBuilder { 19 21 20 Graph<String, Integer> graph;22 Graph<String,Edge<String>> graph; 21 23 22 24 public GraphBuilder(){ 23 graph = new SparseGraph<String, Integer>();25 graph = new SparseGraph<String, Edge<String>>(); 24 26 25 27 } 26 28 27 public Graph<String, Integer> getGraph() {29 public Graph<String, Edge<String>> getGraph() { 28 30 return graph; 29 31 } … … 45 47 String[] splitted = read.trim().split(","); 46 48 vertex.addAll(Arrays.asList(splitted)); 47 graph.addEdge( edge, splitted[0], splitted[1]);49 graph.addEdge(new Edge<String>(splitted[0], splitted[1]), splitted[0], splitted[1]); 48 50 edge++; 49 51 } -
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 } -
branches/localSpectral/src/view/VertexPaintTransformer.java
r27 r32 18 18 19 19 public Paint transform(V node) { 20 if(cluster.contains(node)) 21 return (Paint) Color.GREEN; 20 if(cluster.contains(node)){ 21 Color c = new Color(0,255,0); 22 return (Paint) c; 23 } 22 24 else 23 25 return (Paint) Color.RED; -
branches/localSpectral/src/view/Viewer.java
r27 r32 2 2 package view; 3 3 4 import clustering.VertexScore; 5 import clustering.VertexString; 4 6 import edu.uci.ics.jung.algorithms.layout.FRLayout; 5 7 import edu.uci.ics.jung.algorithms.layout.Layout; … … 8 10 import java.awt.Color; 9 11 import java.awt.Dimension; 12 import java.awt.LayoutManager; 10 13 import java.awt.Paint; 11 14 import java.util.ArrayList; … … 34 37 } 35 38 39 public void setGraph(Graph<V, E> graph) { 40 this.graph = graph; 41 layout.setGraph(graph); 42 frame.repaint(); 43 } 44 45 public void viewGraphRank(List<VertexScore<V>> pagerank, List<V> cluster){ 46 VertexPaintRankTransformer vertexPaint = new VertexPaintRankTransformer(pagerank,cluster); 47 vv.getRenderContext().setVertexFillPaintTransformer((Transformer<V, Paint>) vertexPaint); 48 49 frame.getContentPane().add(vv); 50 frame.pack(); 51 frame.repaint(); 52 frame.setVisible(true); 53 } 54 36 55 37 56 public void viewGraph(List<V> cut){
Note: See TracChangeset
for help on using the changeset viewer.