Database Reference
In-Depth Information
Listing 4.3
Betweenness Centrality calculation
public class BetweennessCentralityExample {
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);
//calculate the betweenness centrality
BetweennessCentrality<UserNode, RetweetEdge> betweenness =
new BetweennessCentrality<UserNode, RetweetEdge>(
retweetGraph);
betweenness.evaluate();
betweenness.printRankings(true, true);
}
}
Source: Chapter4/util/BetweennessScorer.java
4.1.4
Finding Related Information with Networks
All of our network constructions so far have only considered users as nodes and
edges as retweets. We can choose any object as a node and any relation as an edge.
Let's take a look at another network construction that allows us to ask different
questions about our Twitter data.
What if we wanted to see how hashtags are related? There are many valid ways
to measure this, but, true to this chapter, we will measure this using a network-based
approach. We will consider a new network construction where nodes are individual
hashtags and edges are hashtags that co-occur within the same Tweet. We will
weight the edges by the number of times the hashtags co-occur in a Tweet. Because
we do not care about the hashtag order, the edges are not directed. Figure 4.5 shows
an example hashtag network that can be constructed from the topics discussed in
our Occupy Wall Street dataset.
 
Search WWH ::




Custom Search