Changeset 32


Ignore:
Timestamp:
Oct 21, 2010, 9:47:43 PM (14 years ago)
Author:
toshi
Message:
 
Location:
branches/localSpectral
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/localSpectral/nbproject/private/private.properties

    r27 r32  
    11compile.on.save=true
     2do.depend=false
     3do.jar=true
     4javac.debug=true
     5javadoc.preview=true
    26user.properties.file=/home/luke/.netbeans/6.9/build.properties
  • branches/localSpectral/nbproject/project.properties

    r27 r32  
    11annotation.processing.enabled=true
    22annotation.processing.enabled.in.editor=false
    3 annotation.processing.processor.options=
    4 annotation.processing.processors.list=
    53annotation.processing.run.all.processors=true
    64annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
     5application.title=Jung
     6application.vendor=luke
    77build.classes.dir=${build.dir}/classes
    88build.classes.excludes=**/*.java,**/*.form
     
    2525dist.jar=${dist.dir}/Jung.jar
    2626dist.javadoc.dir=${dist.dir}/javadoc
     27endorsed.classpath=
    2728excludes=
    2829file.reference.collections-generic-4.01.jar=/home/luke/Desktop/jung2-2_0_1/collections-generic-4.01.jar
     
    7879# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
    7980# or test-sys-prop.name=value to set system properties for unit tests):
    80 run.jvmargs=
     81run.jvmargs=-Xms1G
    8182run.test.classpath=\
    8283    ${javac.test.classpath}:\
  • branches/localSpectral/src/clustering/LocalSpectral.java

    r27 r32  
    8585
    8686        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());
    9489       
    9590        int volume_graph = 2 * graph.getEdgeCount();
    96         System.out.println("GRAPH VOLUME: " + volume_graph);
    9791        double max_volume = (volume_graph / 3) * 2;
    9892        double min_conductance_subset=100;
     
    10195        int subsets_count = vertexsScore.size();
    10296        for(int i=0; i<subsets_count; i++){
    103             System.out.println("i="+i);
    10497            int volume_subset = 0;
    10598            ArrayList<V> subset = new ArrayList<V>();
     
    127120                    }
    128121                }
    129                 System.out.println("CONDUCTANCE: "+conductance + " minvolume: "+minvolume + " edge_boundary: "+edge_boundary);
     122                //System.out.println("CONDUCTANCE: "+conductance + " minvolume: "+minvolume + " edge_boundary: "+edge_boundary);
    130123            }
    131124
    132125        }
    133         System.out.println("MIN CONDUCTANCE: "+min_conductance_subset + " INDEX "+min_conductance_index );
     126        System.out.println("MIN CONDUCTANCE: "+min_conductance_subset);
    134127
     128        System.out.println("CLUSTER: ");
    135129        List<V> cluster = new ArrayList<V>();
    136130        for(int i=0; i< min_conductance_index; i++)
    137131            cluster.add(vertexsScore.get(i).getVertex());
     132
     133        for(V node : cluster)
     134            System.out.println(node.toString());
    138135       
    139136        return cluster;
  • branches/localSpectral/src/data/GraphBuilder.java

    r27 r32  
    22package data;
    33
     4import clustering.Edge;
     5import clustering.VertexString;
    46import edu.uci.ics.jung.graph.Graph;
    57import edu.uci.ics.jung.graph.SparseGraph;
     
    1618
    1719
    18 public class GraphBuilder<V,E> {
     20public class GraphBuilder {
    1921
    20     Graph<String,Integer> graph;
     22    Graph<String,Edge<String>> graph;
    2123
    2224    public GraphBuilder(){
    23         graph = new SparseGraph<String, Integer>();
     25        graph = new SparseGraph<String, Edge<String>>();
    2426
    2527    }
    2628
    27     public Graph<String, Integer> getGraph() {
     29    public Graph<String, Edge<String>> getGraph() {
    2830        return graph;
    2931    }
     
    4547                    String[] splitted = read.trim().split(",");
    4648                    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]);
    4850                    edge++;
    4951                }
  • branches/localSpectral/src/jung/Main.java

    r27 r32  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
    51
    62package jung;
    73
     4import clustering.Edge;
    85import clustering.LocalSpectral;
    96import clustering.VertexScore;
     7import clustering.VertexString;
    108import data.GraphBuilder;
    119import edu.uci.ics.jung.algorithms.scoring.PageRank;
     10import edu.uci.ics.jung.graph.AbstractGraph;
    1211import edu.uci.ics.jung.graph.Graph;
    1312import edu.uci.ics.jung.graph.SparseGraph;
     
    2322    public static void main(String[] args) {
    2423       GraphBuilder builder = new GraphBuilder();
    25        builder.buildGraphFromARFF("/home/luke/Desktop/reteSemplice.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);
    3029       List<VertexScore<String>> global_ranking = clusterer.getGlobalRank();
     30
    3131       System.out.println("GLOBAL RANKING");
    3232       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       
    3440       for(VertexScore<String> v : global_ranking){
    3541           Long stoptime = 5000L;
     
    3844            } catch (InterruptedException e) {}
    3945           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);
    4163       }
     64       
    4265
    4366    }
  • branches/localSpectral/src/view/VertexPaintTransformer.java

    r27 r32  
    1818
    1919    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      }
    2224      else
    2325         return (Paint) Color.RED;
  • branches/localSpectral/src/view/Viewer.java

    r27 r32  
    22package view;
    33
     4import clustering.VertexScore;
     5import clustering.VertexString;
    46import edu.uci.ics.jung.algorithms.layout.FRLayout;
    57import edu.uci.ics.jung.algorithms.layout.Layout;
     
    810import java.awt.Color;
    911import java.awt.Dimension;
     12import java.awt.LayoutManager;
    1013import java.awt.Paint;
    1114import java.util.ArrayList;
     
    3437    }
    3538
     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
    3655
    3756    public void viewGraph(List<V> cut){
Note: See TracChangeset for help on using the changeset viewer.