First we include
igraph and
numpy:
Next, we create a graph by specifying the vertices and edge pairs:
Now we can apply styling to better visualize the data. We can, for example, scale the vertices based on their (out)degree, and color them accordingly:
We can also add the calculated (out)degree to the label of the vertex:
Furthermore, we can set the edge weights based on the communities detected with community detection:
To make the graph look somewhat nicer, apply a little bit more styling:
Finally, plot the graph:
The final diagram now looks like this:
The full code can be found
here, more examples can be found
here.