{ "cells": [ { "cell_type": "code", "execution_count": 57, "metadata": { "collapsed": true }, "outputs": [], "source": [ "#libraries\n", "\n", "import random\n", "import matplotlib.pyplot as plt\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 77, "metadata": { "collapsed": true }, "outputs": [], "source": [ "#Creation of the directed random regular graph according to Configuration model (Bollobas paper), with kout fixed\n", "#Think to a different kin, kout (kin is function of kout someway)\n", "\n", "def RRG_direct(k,N):\n", " bool_graph = 0\n", " while bool_graph == 0:\n", " #print('ok')\n", " bool_graph = 1\n", " buckets = [[] for i in range(N)]\n", " edges_out = []\n", " edges_in = []\n", " edge_list_out = [[] for i in range(N)]\n", " edge_list_in = [[] for i in range(N)]\n", " pool_out = [i for i in range(N*k)]\n", "\n", " i=0\n", " j=0\n", " while i" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "#Plots for random regular graphs\n", "#Remember to specify the kout of the graph and get results for many different kout\n", "\n", "dim_arr = [10, 50, 100, 500, 1000, 5000]\n", "log_dim_arr = np.log10(np.asarray(dim_arr))\n", "\n", "\n", "\n", "plt.errorbar(log_dim_arr, r_try[0], yerr=r_try[1], fmt='--o', label='C from numerics')\n", "plt.plot(log_dim_arr, r_try[2], 'x', label='C from theory')\n", "plt.xlabel('Net size')\n", "plt.ylabel('# reciprocated arcs')\n", "plt.title('Comparison reciprocated arcs numerics vs theory')\n", "plt.legend()\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [default]", "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.6.2" } }, "nbformat": 4, "nbformat_minor": 2 }