Analysing the #бојкотирам movement on Twitter


Importing tweet data

  • using pandas to read csv file
Loading output library...

Removing duplicates


Since the data wasn't collected in one go there are duplicates we need to remove

Creating the NetworkX Graph object


First let's make sure we are using nx version 2.1

Import edges from pandas to NetworkX.Graph for the retweet network


The graph will be a directed multi graph where the source is the author of the tweet, and the target is the original author of the tweet.

We will need to remove the rows where we don't have an original author, i.e. the tweets that aren't retweets or quotes

Visualizing the graph

Loading output library...

Network degrees

Loading output library...
Loading output library...

We can see that the out degrees follow power-law

Calculating PageRank for the network


And displaying the top 30 nodes

Loading output library...

Community detection using the Girvan-Newman method


The idea is there will be 2 large communities where one side is the people actually boycotting, and the other side will be the people criticizing the people who are boycotting, which is why we are only getting the first touple of communities detected by the GN algorithm

Color-coding the nodes in the communities

Loading output library...

Visualizing the communities

Loading output library...

Let's check if the communities are actually the two opposing groups


We'll compare the top 10 most retweeted people in both communities and their top tweets

Converting to weighted directional graph


The weight is the number of edges connecting the two nodes in the multi graph

Loading output library...