summaryrefslogtreecommitdiff
path: root/src/Chapter4/centrality/examples/EigenvectorCentralityExample.java
blob: 172dd16a5adb059671056ce77480c5a8548f192a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package centrality.examples;

import Chapter4.util.TweetFileToGraph;
import java.io.File;
import GraphElements.RetweetEdge;
import GraphElements.UserNode;
import edu.uci.ics.jung.algorithms.scoring.EigenvectorCentrality;
import edu.uci.ics.jung.graph.DirectedGraph;

public class EigenvectorCentralityExample {
	public static void main(String[] args){
		
		File tweetFile;
		
		if(args.length > 0){
			tweetFile = new File(args[0]);
		}
		else{
			tweetFile = new File("synthetic_retweet_network.json");
		}
		
		DirectedGraph<UserNode, RetweetEdge> retweetGraph = TweetFileToGraph.getRetweetNetwork(tweetFile);
		
//		EigenVectorScorer scorer = new EigenVectorScorer(retweetGraph);
//		for(UserNode node : retweetGraph.getVertices()){
//			System.out.println(node + " - " + scorer.getVertexScore(node));
//		}
		
		EigenvectorCentrality<UserNode, RetweetEdge> eig = new EigenvectorCentrality<UserNode, RetweetEdge>(retweetGraph);
		eig.evaluate();
		
		for(UserNode node : retweetGraph.getVertices()){
			System.out.println(node + " - " + eig.getVertexScore(node));
		}
	}
}