I am trying to visualize retweet network in order to find out which users are most likely to have most influence on other users. Here is my code:

    import networkx as nx

G_retweet = nx.from_pandas_edgelist(translated_iranian_tweets,
source = "userid",
target = "retweet_userid",
create_using = nx.DiGraph())

print('There are {} Nodes inside Retweet Network'.format(len(G_retweet.nodes())))
print('There are {} Edges inside Retweet Network'.format(len(G_retweet.edges())))

import matplotlib.pyplot as plt

#Size varies by the number of edges the node has (its degree)
sizes = [x[1] for x in G_retweet.degree()]

nx.draw_networkx(G_retweet,
pos = nx.circular_layout(G_retweet),
with_labels = False,
node_size = sizes,
width = 0.1,
alpha = 0.7,
arrowsize = 2,
linewidths = 0)

plt.axis('off')
plt.show()


There are 18631 nodes and 35008 edges inside this network. Visualization is horrible, you cannot see anything. Does anyone have any suggestions what should I do about it? Should I try to extract specific type of users with specific tweets in order to reduce size of my dataset and then try to visualize the network, or something else?

• Can you tell me which dataset you were working on? Jan 15 '19 at 10:14

For answering questions from graph, you should not visualize it. Visualizing graphs is for sake of having an overview on how it looks like in general. There are Graph Visualization techniques that show graph for sake of getting some initial insight (e.g. if there are visually obvious communities or not).

Your question has an analytic answer. After constructing your graph object, you can get the adjacency matrix as a Python array or matrix. This matrix will be asymmetric as outgoing and incoming degrees are different of course. In Networkx you can get in-degree and out-degree information as seen below. Then the main story starts!

The most influential of a social network can be seen as the most central node. Centrality measures capture them for you. The simplest one is degree centrality. It simply says the node with highest degree has most influence in graph. In your case be sure how you model "the guy who is retweeted"as he has the most influence. If being retweeted is in-degree in your modeling then this code get them for you:

import networkx as nx
import operator

g=nx.digraph.DiGraph()
dict_deg = {ii:jj for (ii,jj) in g.in_degree}
print('In-Degree Dictionary\n',dict_deg)

m = max(list(dict_deg.values()))
print('The node(s) number',[i for i, j in enumerate(list(dict_deg.values())) if j == m],'have the most influence!')


Output:

In-Degree Dictionary
{0: 0, 1: 1, 2: 2, 3: 2, 4: 0}
The node(s) number [2, 3] have the most influence!


And the graph itself:

pos = nx.spring_layout(g)
_=nx.draw(g,label=True,pos=pos)
_=nx.draw_networkx_labels(g,pos=pos)