{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Simulate Evolution of Graphs\n\n.. raw:: html\n\n   <center>\n\nThe Notebook Below Simulates an Evolving Graph based on the\nSusceptible-Infected Susceptible model\n\n.. raw:: html\n\n   </center>\n\n###\n\n.. raw:: html\n\n   <center>\n\nThe code produces trajectories in terms of the fraction of the infected\npopulation $      heta_I$ and the fraction of the edges between the\nsusceptible population $g_{ss} $\n\n.. raw:: html\n\n   </center>\n\nReferences:\n\n-  Gross, Thilo, and Ioannis G. Kevrekidis. \u201cRobust oscillations in SIS\n   epidemics on adaptive networks: Coarse graining by automated moment\n   closure.\u201d EPL (Europhysics Letters) 82.3 (2008): 38004.\n-  Kattis, Assimakis A., et al.\u00a0\u201cModeling epidemics on adaptively\n   evolving networks: a data-mining perspective.\u201d Virulence 7.2 (2016):\n   153-162.\n\n## Dependencies\n\n-  numpy pip install numpy\n-  matplotlib pip install matplotlib\n-  tqdm pip install tqdm\n\n.. raw:: html\n\n   <center>\n\nOne sampled trajectory for $p=0.00075$ from the evolving graph is\nshown in the figure below\n\n.. raw:: html\n\n   </center>\n\n.. figure:: attachment:Trajectory_display.png\n   :alt: Trajectory_display.png\n\n   Trajectory_display.png\n\n.. code:: ipython3\n\n    import numpy as np\n    import matplotlib.pyplot as plt\n    from tqdm.notebook import tqdm\n    from Full_Network_Functions import * ## \n    \n    plt.rc('xtick', labelsize=20)\n    plt.rc('ytick', labelsize=20)\n    plt.rc('axes', labelsize=21)\n    plt.rc('font', family='serif')\n    plt.rc('font', family='serif')\n    plt.rcParams['image.cmap'] = 'Spectral'\n    np.random.seed(2)\n\n### Parameters Used For The Simulation Below\n\nThe Parameters governing: \\* The number of Nodes, $N=10,000$ \\*\nThe number of Edges, $L=100,000$ \\* The inital fraction of\nInfected people, $Y_0 =0.5$ are kept fixed on the\nFull_Network_Functions.py file.\n\n.. code:: ipython3\n\n    w0 = 0.06 #rewiring parameter\n    r = 0.0002 #recover probability\n    p = 0.00075 #infection parameter\n\n### Load an initial configuration of the graph \n\nThe user can choose between initializing a random graph or loading an\nexisting graph\n\n.. code:: ipython3\n\n    data = load_initial_graph_question()\n\n\n.. parsed-literal::\n\n    Do you want to load an existing graph? (yes or no)yes\n\n\n### Run Simulations for the graph\n\nFor $p=0.00075$ you might need to run about 20,000 steps (~20\nmins) to capture the stable limit cycle\n\n.. code:: ipython3\n\n    Number_of_Steps=int(input('Select the Number of Time Steps:' ))\n    stat_list = []\n    I_node = data[0];edge_list = data[1]\n    stat_array, I_node, edge_list = iterate(I_node, edge_list, Number_of_Steps,r, p,w0)\n\n\n.. parsed-literal::\n\n    Select the Number of Time Steps:100\n\n\n.. parsed-literal::\n\n    100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 100/100 [00:07<00:00, 12.93it/s]\n\n\n.. code:: ipython3\n\n    fig = plt.figure(figsize=(4*3,4))\n    ax = fig.add_subplot(131)\n    ax.plot(stat_array[:,0],'.k')\n    ax.set_ylabel(r'$   heta_I$')\n    ax.set_xlabel('Iterations')\n    \n    ax = fig.add_subplot(132)\n    ax.plot(stat_array[:,1],'.k')\n    ax.set_ylabel(r'$g_{ss}$')\n    ax.set_xlabel('Iterations')\n    \n    ax = fig.add_subplot(133)\n    ax.plot(stat_array[:,0],stat_array[:,1],'.k')\n    ax.set_ylabel(r'$g_{ss}$')\n    ax.set_xlabel(r'$   heta_I$')\n    \n    plt.tight_layout()\n\n\n\n<img src=\"file://output_14_0.png\">\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}