{{ message }}

Instantly share code, notes, and snippets.

# Davis Nascimento davisvictorns

• Infoprime Sistemas
Created Sep 15, 2021
View napf5.py
 # degree sequence count_sequence = sorted([data['count'] for node, data in list(G.nodes.data())], reverse=True)[1:] fig, ax = plt.subplots(1,2,figsize=(8,4)) # all_data has information about count_sequence and the width of each bin ax[0].hist(count_sequence) ax[1].hist(count_sequence,bins=[x for x in range(80)]) ax[0].set_title("count Histogram")
Created Sep 15, 2021
View napf4.py
 plt.style.use("default") # degree sequence degree_sequence = sorted([d for n, d in G.degree()], reverse=True) fig, ax = plt.subplots(1,2,figsize=(8,4)) # all_data has information about degree_sequence and the width of each bin ax[0].hist(degree_sequence) ax[1].hist(degree_sequence,bins=[x for x in range(50)])
Created Sep 15, 2021
View napf3.py
 edg_copy = edges.copy() edge_with_weight = [] while len(edg_copy) > 0: curr_edge = edg_copy[0] equivalent_edges = [] # get the equivalent edges # ('a', 'b') is equivalent to ('b', 'a') because it's not a directed connection for edge in edg_copy: is_different = False for hashtag in edge:
Created Sep 15, 2021
View napf2.py
 edges = [] nodes = [] for i, row in df.iterrows(): curr_hashtags = row['hashtags'].split(' ') nodes += curr_hashtags combinations = list(itertools.combinations(curr_hashtags, 2)) edges += combinations nodes_unique = set(nodes)
Last active Sep 15, 2021
View napf1.py
 c = twitter.cursor(twitter.search, q='#7deSetPelaLiberdade', count=100, result_type='mixed', tweet_mode='extended') tweets = [] count = 0 n_tweets = 30000 for tweet in c: count += 1 tweets.append(tweet) # each 100 tweets requires 1 request # sleep after 180 requests if count > 0 and count % (180 * 100) == 0:
Created Dec 18, 2020
View nx_scatter..py
 plt.scatter(degree, clustering) plt.xlabel("Degree") plt.ylabel("Clustering") plt.show()
Created Dec 18, 2020
View nx_graficos.py
 degree = [G.degree(node) for node in G.nodes] clustering = [nx.clustering(G, node) for node in G.nodes] plt.hist(clustering) plt.show() plt.boxplot(clustering) plt.show()
Created Dec 18, 2020
View nx_clustering.py
 acc = nx.average_clustering(nx.Graph(G)) acc
Created Dec 18, 2020