Examining Twitter Hashtags Surrounding the Ukraine-Russia Conflict

Tdeaner
INST414: Data Science Techniques
4 min readApr 18, 2022

The invasion of Ukraine by Russia has been one of the most talked-about and covered news stories of this year since the conflict began in February. For this assignment, I wanted to develop a network graph of Twitter hashtags to see what aspects of the conflict are the most discussed on Twitter. From these insights, perhaps news companies can understand what readers may be more interested in reading.

I collected my data using the Twitter Streaming Import plugin of the Gephi network analysis program. This import, assuming you have a Twitter developer account, allows for the real-time collection of tweets that contain any keyword of your choice. This means whenever someone tweets something with a certain word in the tweet, the tweet is added to a newly created network graph. After specifying in the plugin options that I wanted to collect tweets that contain either the word “Ukraine” or “Russia”, that I only wanted English tweets, and that I only needed to collect the hashtags attached to the tweets, I began my data collection.

I collected real-time data from Twitter for about only 5 minutes, because otherwise there would be too much data and the network graph would look incomprehensible. This is what the graph looked like before I made any adjustments to it.

Each node represents a different hashtag that was included in a tweet, and each edge, or the lines connecting one node to another, represents whenever a hashtag was used in the same tweet as another hashtag. I decided to collect some statistics about the network, such as the average degree. The average degree was 3.96, meaning that on average, one single hashtag was used in conjunction with about 4 other hashtags. There are also 8 connected components, or subgraphs, within this graph. Since this graph looks a little messy, I decided to adjust some settings within Gephi to make the graph more understandable.

Before adjusting the layout of the graph, I changed the appearance of the network by assigning a color to the nodes based on which connected component they belong to. I also added a ranking system to calculate the size of each node based on the degree of the nodes, meaning that the size of the node is dependent on how many other nodes it is connected to. Finally, I labeled each node with the hashtag that the node represents. Now that I was happy with the appearance of the graph, I went on the adjust the layout of the graph.

I ran the circular layout option, with the setting that allowed each connected component to be separated from one another. The graph was still a little messy even with these adjustments, so I had to manually move some of the more important nodes (such as #standwithukraine) to make them stand out from some of the smaller nodes. I then exported my final graph within the ‘preview’ section of Gephi, and this is how the graph came out:

Based on the graph, it seems like support for Ukraine is something that pops up a lot on Twitter. Additionally, Russian President Putin appears to be a common topic, with some of the associated hashtags relating Putin and his leadership to Nazi Germany and the Soviet Union. Interestingly, despite not directly being involved in the conflict, the United States also appears to be a common topic when discussing the Ukraine-Russian conflict.

The main issue I had making the graph was not the actual production of the graph, but rather the process of setting up a developer account for Twitter. When I first signed up for a developer account, I was immediately given access to the Essential Twitter API tier, which provides access to Twitter API v2. My problem came when I tried to put my account credentials into the Twitter Streaming Importer plugin to start collecting data for my graph, but the plugin only works with Twitter API v1.1 and not v2. I did not know this starting out, so it was confusing to me why my credentials were not working. After doing some research I figured out that I needed access to Twitter API v1.1, and applied for access to the Elevated Twitter API tier, which I was given pretty quickly. From there, everything was pretty much smooth-sailing.

The main takeaway from this network analysis is that the three biggest topics on Twitter concerning the Ukraine-Russia conflict are Twitter users showing their support for Ukraine, Putin, and the United States. I believe that I could have collected a bit more data for my graph because there seems to be a lot of whitespace in the graph, but for now, I am content with my first attempt at making a network graph.

--

--