summaryrefslogtreecommitdiff
path: root/src/Chapter4/centrality/examples/EigenvectorCentralityExample.java
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-04-23 12:22:20 +0200
committerPeter Wu <peter@lekensteyn.nl>2014-04-23 12:22:20 +0200
commit14d7547cd31c5be878e377a4a5370f604c8d59d4 (patch)
tree003840f1a21d39b07d45cd3112c38b6eed40e3ab /src/Chapter4/centrality/examples/EigenvectorCentralityExample.java
downloadTwitterDataAnalytics-14d7547cd31c5be878e377a4a5370f604c8d59d4.tar.gz
Initial commit
build.xml, etc. are modified a bit after opening in Netbeans 7.4.
Diffstat (limited to 'src/Chapter4/centrality/examples/EigenvectorCentralityExample.java')
-rw-r--r--src/Chapter4/centrality/examples/EigenvectorCentralityExample.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Chapter4/centrality/examples/EigenvectorCentralityExample.java b/src/Chapter4/centrality/examples/EigenvectorCentralityExample.java
new file mode 100644
index 0000000..172dd16
--- /dev/null
+++ b/src/Chapter4/centrality/examples/EigenvectorCentralityExample.java
@@ -0,0 +1,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));
+ }
+ }
+}