Ignore:
Timestamp:
Oct 21, 2010, 9:47:43 PM (14 years ago)
Author:
toshi
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.