The goal of this assignment is to write code that can replicate the main plot in the Watts-Strogatz paper. You can use any programming language you want. Feel free to use matrix or graph libraries that already implement helpful classes and functions, unless I instruct you otherwise. Work on this assignment individually.
generate_watts_strogatz_graph
to generate randomised ring graphs using the Watts-Strogatz model. The function should take three parameters: \(n\), \(k\), and \(p\). Here \(n\) is the number of the nodes in the network, \(k\) is the degree of each node, and \(p\) is a probability between \(0\) and \(1\). The parameters \(n\) and \(k\) are integers and \(k\) can be even. A single call to this function should create an undirected, regular, ring graph with \(n\) nodes and \(nk/2\) edges, and then rewire every edge with probability \(p\), as described in the caption of Figure 1 of Collective dynamics of 'small-world' networks. Recall that in a regular graph, all nodes have the same degree. Therefore, in this graph, each node has degree \(k\). If the graph is disconnected after rewiring, rewire repeatedly until it is connected (i.e., all nodes are in the same connected component). Implement this function yourself. Do not use a ready-made implementation in some other package or library.Here are some guidelines to keep in mind:
Some additional notes:
pip install --user networkx
to install the package in your own directory on rlogin. Obtain your results and then transfer them to some computer where you have more power on installing packages in order to the plot the results.Turn in a typeset (not handwritten) report describing your results and the plots. Mention any difficulties you encountered and how you addressed them. Were there any surprises, i.e., results or trends you did not expect? I am also curious to find out what you learnt from this assignment.