A beginner’s tutorial on Social Network Analysis – (Part 2)

In this part, we will talk about visualizing our network.

  • Tools used for this tutorial: networkX, matplotlib

In Part 1 of this tutorial, we talked of a graph having 5 nodes (a,b,c,d,e) and the edges [(a,b), (b,c), (c,d)]. Let”s add one more edge (b,d)

Matplotlib is a set of plotting tools for python. You can download and install it from a package manager of your choice, or install it from source. This can take care of advanced 2D plotting for python. We will use this to plot our network.

the rendered graph


All the parameters in nx.draw() are self explanatory.NetworkX has the following layouts:

  • Graphviz and pydot layout
  • circular layout (places nodes in a circle)
  • random layout (positions nodes based on an uniform distribution in a unit square.
  • shell layout (places nodes in concentric circles)
  • spring layout (places nodes using Fruchterman-Reingold force-directed algorithm )
  • spectral layout (positions nodes using eigen vectors of the graph laplacian)


You can tinker with different layouts and select the one that best suits your needs.To show you the types of visualizations rendered, I am posting some renders below :


Portion of a large graph in random layout

co-authorship graph of faculties in CSE dept. IIT Madras


In the next parts, we will work on some real network, like twitter followers network or IMDB co-star network or DBLP co-authorship network and check models for link prediction, homophily, information cascades and epidemics, community detection etc.

Thanks for following this tutorial.

Leave a Reply