Node Network of @PlayValorant Twitter Followers

Teja Tammali
INST414: Data Science Techniques
3 min readFeb 26, 2022

It is no surprise that the social media world can connect thousands if not millions of people ranging across several countries. To map this, I wanted to identify a non-obvious insight on the data I extracted from the Twitter API. How is the data linked from the first few friends of a Twitter account compared to the first few of each of them? It can be crazy how people you know are followed by thousands of other people that you aren’t even aware of. From this, I would like this insight to provide the ability to visualize how the few friends are connected to each other in the manner of a network.

The source of the network data comes from the Twitter API (developer.twitter.com). From retrieving the data using the Twitter API, I set the target Twitter account to @PlayValorant. I then proceeded to enable the code to look throughout the first 50 friends of the account and then the first 50 of the already checked accounts. By collecting data in this way, it can be determined if the friends selected have a connection with each other based on the following status. The nodes in the network represent the different entities of the first 50 friends and the edges represent the connection the friends have with each other (following status). After I gather this data, I checked to see how many total nodes and edges were represented in the graph. The network resulted in 1528 nodes and 1869 edges. After that, I proceeded to use the Network X framework to create the network graph by writing the following code and resulting in:

print(len(g.nodes()))
print(len(g.edges()))

After that, I proceeded to use the Network X framework to create the network graph by writing the following code and resulting in:

x.draw(g, with_labels = True)
plt.show()
Network graph of @PlayValorant Friends
pos = nx.spring_layout(g, iterations=200)
nx.draw(g, pos, node_color=range(len(g.nodes())), node_size=800, cmap=plt.cm.Blues)
plt.show()
Node Colored Network Graph
max_c = max(centrality.values())
color_map = {x[0]:x[1]/max_c for x in centrality.items()}
nx.draw(g, pos, node_color=list(color_map.values()), node_size=800, cmap = plt.cm.hot)
plt.show()
Centrality Colored Network Graph

One bug I encountered is getting the data to process the first few (50) friends of the accounts. I made a mistake making a while look instead of for loop. Having the code written as a while look, the amount of friend count would exceed what was initially set as it became an infinite loop due to improper counter. By using my critical thinking skills, I quickly decided a for loop would be much more efficient and easier to deal with. While working with the for loop, the code was taking a longer time to finish executing due to the number of friends that was set to the variable of friend amount. To solve that issue, I lowered the friend count to 50 which was initially set to 100. Data cleaning-wise, there wasn’t much to do. The framework, Tweepy, already gave out clean data which were just Twitter accounts. All I had to do is retrieve the 50 accounts and set them into nodes and edges using the NetworkX framework.

The limitations for this project include the lower disk reading speed and lowered runtime for Google Colab. Due to the lower disk reading speed, it took a long time to read in the data meaning the API could only read in a certain amount of data for the limited runtime. My main takeaway is that people of similar interests are much more likely to follow each other and the main account. For example, in this case, people who are content creators for the game were more likely to be friends while at the same time, following the @PlayValorant Twitter account.

--

--