def reciprocity_per_time_step(time_step=60*60): """Plots the reciprocity of all tweets in the UMG for a given time slice.""" ranges = t.get_range() first_tweet = ranges[0] last_tweet = ranges[(len(ranges)-1)] start_index = first_tweet to_graph = [] x_vals = [] while start_index < last_tweet: last_index = start_index + datetime.timedelta(seconds=time_step) x_vals.append(f.roundTime(start_index,60*60)) print str(start_index) tweets = bf.get_tweets_between(start_index, last_index) print "Tweets found:", len(tweets), "Making Graph" graph = um.user_mentions_graph(tweets) reciprocity = f.get_graph_reciprocity(graph) to_graph.append(reciprocity) start_index += datetime.timedelta(seconds=time_step) plt.plot(x_vals,to_graph) locs, labels = plt.xticks() plt.setp(labels, rotation=90) plt.title('Reciprocity by Hour') plt.xlabel('Date') plt.ylabel('Reciprocity') plt.show() return to_graph
def hashtag_changes(time_step = 60*60*24): """Attempting to identify changes in the hashtag structure overtime""" ranges = t.get_range() first_tweet = ranges[0] last_tweet = ranges[len(ranges)-1] index = first_tweet print first_tweet, last_tweet to_graph = [] while index < last_tweet: index += datetime.timedelta(seconds=time_step) tweets = bf.get_tweets_between(first_tweet, index) #Now make the user tweet graph graph = ut.create_user_tweet_graph(tweets) print "Tweets before", index, ":", len(tweets) to_graph.append(len(nx.connected_components(graph))) f.draw_graph(y=to_graph, x_label="Days", y_label="Number of Components", title="Cumulative Connected Components")