This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Username,Followers,List Count,URI | |
aplusk,10137792,343,http://www.twitter.com/aplusk | |
JimCarrey,7159113,297,http://www.twitter.com/JimCarrey | |
tomhanks,3773553,288,http://www.twitter.com/tomhanks | |
ActuallyNPH,3061975,283,http://www.twitter.com/ActuallyNPH | |
NathanFillion,1222189,232,http://www.twitter.com/NathanFillion | |
RedHourBen,2655373,230,http://www.twitter.com/RedHourBen | |
peterfacinelli,1937513,215,http://www.twitter.com/peterfacinelli | |
Alyssa_Milano,2016472,214,http://www.twitter.com/Alyssa_Milano | |
KevinSpacey,2259294,210,http://www.twitter.com/KevinSpacey |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generate_most_listed_members | |
seen_lists = [] | |
seen_membersets = [] | |
@tmp_persons = [] | |
self.persons.each do |person| | |
#puts person.username | |
@tmp_persons << {:username => person.username, :list_count => 1, | |
:uri => "http://www.twitter.com/#{person.username}", :followers => person.followers_count, | |
:friends => person.friends_count} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.collect_list_members(username, list_id,project_id) | |
while Project.get_remaining_hits == "timeout" | |
puts "collect_list_members waiting..." | |
sleep(60) | |
end | |
result = @@twitter.list_members(username, list_id, {:cursor => -1}) | |
members = result["users"] | |
next_cursor = result["next_cursor"] | |
old_next_cursor = 0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.collect_list_memberships(username, project_id = "") | |
page_size = LIST_PAGE_SIZE | |
attempts = 0 | |
while Project.get_remaining_hits == "timeout" | |
puts "collect_list_memberships waiting..." | |
sleep(60) | |
end | |
begin | |
result = @@twitter.memberships(username, {:cursor => -1, :count => page_size}) | |
lists = result["lists"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reciprocity(D): | |
G=D.to_undirected() # copy | |
for (u,v) in D.edges(): | |
if not D.has_edge(v,u): | |
G.remove_edge(u,v) | |
return float(len(G.edges()))/len(D.to_undirected().edges()) | |
# A simple test: | |
G = nx.DiGraph() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def total_edge_weight(D): | |
total = 0 | |
for edge in D.edges(data=True): | |
total += edge[2]["weight"] | |
return total | |
def average_tie_strength(D): | |
return float(total_edge_weight(D))/len(D.edges()) | |
D = nx.DiGraph() |
NewerOlder