1
0
mirror of https://github.com/gsi-upm/sitc synced 2024-11-17 20:12:28 +00:00
sitc/sna/4_Social_Networks.ipynb

866 lines
1.0 MiB
Plaintext
Raw Permalink Normal View History

2024-04-17 15:23:28 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"![](images/EscUpmPolit_p.gif \"UPM\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"# Course Notes for Learning Intelligent Systems"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"## [Introduction to Network Analysis](0_Intro_Network_Analysis.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Social Networks"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"outputs": [],
"source": [
"# from networkx documentation\n",
"# Plot degree distribution \n",
"\n",
"import collections\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# We convert first the graph from directed to undirected\n",
"\n",
"def plot_degree_histogram(G):\n",
" degree_sequence = sorted([d for n, d in G.degree()], reverse=True) # degree sequence\n",
" # print \"Degree sequence\", degree_sequence\n",
" degreeCount = collections.Counter(degree_sequence)\n",
" deg, cnt = zip(*degreeCount.items())\n",
" fig, ax = plt.subplots()\n",
" plt.bar(deg, cnt, width=0.80, color='b')\n",
" plt.title(\"Degree Histogram\")\n",
" plt.ylabel(\"Count\")\n",
" plt.xlabel(\"Degree\")\n",
" ax.set_xticks([d + 0.4 for d in deg])\n",
" ax.set_xticklabels(deg)\n",
" plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Regular graph"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"outputs": [],
"source": [
"import networkx as nx\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# from Think Complexity\n",
"def adjacent_edges(nodes, halfk):\n",
" n = len(nodes)\n",
" for i, u in enumerate(nodes):\n",
" for j in range(i+1, i+halfk+1):\n",
" v = nodes[j % n]\n",
" yield u, v\n",
" \n",
"def make_ring_lattice(n, k):\n",
" G = nx.Graph()\n",
" nodes = range(n)\n",
" G.add_nodes_from(nodes)\n",
" G.add_edges_from(adjacent_edges(nodes, k//2))\n",
" return G\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAgQAAAGFCAYAAACCBut2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAB+8UlEQVR4nO3ddVxU2fsH8M/QIQ0qiigWaxcWCAIuoQgqBmuLqAjGiq7dHeuKSZi4dmArpaKEit0dWKDSIM3M+f3B1/nJSgwwAcPzfr32tbvDvec8MHDPM/eecx4OY4yBEEIIITWajKQDIIQQQojkUUJACCGEEEoICCGEEEIJASGEEEJACQEhhBBCQAkBIYQQQkAJASGEEEIAyAlyEI/HQ1xcHNTU1MDhcEQdEyGEEEKEgDGGjIwM1KtXDzIypd8DECghiIuLQ4MGDYQSHCGEEELE6+PHjzAwMCj1GIESAjU1NX6D6urqlY+MEEIIISKXnp6OBg0a8Mfx0giUEPx4TKCurk4JASGEEFLNCPK4nyYVEkIIIYQSAkIIIYRQQkAIIYQQUEJACCGEEFBCQAghhBBQQkAIIYQQUEJACCGEEFBCQAghhBBQQkAIIYQQUEJACCGEEFBCQAghhBB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DZtWrHN3717F15eXoiIiEDv3r3xzz//oEWL8pZbIkR4yjV+MwGkpaUxACwtLU2QwwkRqsTERDZ58mQmKyvLGjduzAIDAxmPxyvx+ICAAAaAzZ49W7AOCgoYy8hkLC2j8N8FBUKKXDw+fPjA9u7dy8aMGcMaNmzIADAZGRnWqVMnNnPmTHbhwgWWnp5e4fb
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"L = make_ring_lattice(10,4)\n",
"pos = nx.circular_layout(L)\n",
"nx.draw_networkx(L, pos=pos, with_labels=True, node_size=300, node_color='pink')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"1.6666666666666667"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Average shortest path\n",
"nx.average_shortest_path_length(L)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAHHCAYAAACle7JuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAnwklEQVR4nO3de1SVdb7H8c8WEYjLxhsgioDmoJlRirXQylSUTD1qq5xpnATP6HgML+Qpkxo0M2Ps4lCNk+ac1FNSjlbmmkkdL1mWTuIlL3PU1NRQEy8IG1S2Cs/5Y5Z7tQMUCNz7p+/XWqzk9zx7P1/2H8N7nufZbJtlWZYAAAAM1MDTAwAAANQWIQMAAIxFyAAAAGMRMgAAwFiEDAAAMBYhAwAAjEXIAAAAYxEyAADAWIQMAAAwFiED4IZis9n0/PPPe3oMANcJIQN4oQULFshms7m+/P39FRkZqeTkZL3xxhsqLi729IjXxfPPPy+bzabTp09Xuj0mJkYDBgz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VNt3rxZb775po4ePaolS5a4PUdZWZn69eun+++/Xy+//LIWLVqksWPHKjAwUM8995yGDRumhx9+WHPmzNHw4cOVmJio2NjYa75egHEsAF5n/vz5liQrNze3yn3sdrt11113ub7v3bu31alTJ6u0tNS1Vl5ebnXr1s1q166da23cuHGWzWaztm/f7lo7c+aM1aRJE0uSdejQIdd6dHS0JclauXKl27GnT59uBQYGWt9++63b+uTJky0fHx/r+++/tyzLsjZs2GBJshYtWuS238qVKytd/6mpU6dakq761b9/f7fHSLKmTp3q9jqlpaVd9Tj9+/e3oqOjK6xnZ2dbkqz33nvPtXbx4kUrMTHRCgoKshwOh2VZlvXhhx9akqzs7GzXfmVlZVavXr0sSdb8+fNd6ykpKZYka/LkyRWOd/78+QprWVlZls1ms44cOVLhOV566SXX2tmzZ62AgADLZrNZH3zwgWt97969FV4T4EbCpSXAUEFBQa53LxUUFGjdunUaOnSoiouLdfr0aZ0+fVpnzpxRcnKy9u/fr2PHjkmSVq5cqcTERN15552u52rSpInr8sZPxcbGKjk52W1tyZIluu+++9S4cWPXsU6fPq2kpCSVlZXpiy++cO1nt9vVp08ft/26dOmioKAgffbZZ9X6WT/88EOtXr26wld4ePg1HxsaGqqvv/5ax48fr9axfuzTTz9VRESEHnvsMdear6+vxo8fr5KSEn3++eeS/v2a+vr6us6OSVKDBg2UlpZW5XOPGTOmwtqP7z06d+6cTp8+rW7dusmyLG3fvr3C/iNHjnT9OzQ0VHFxcQoMDNTQoUNd63FxcQoNDdV3331XzZ8aMAuXlgBDlZSUKCwsTJJ04MABWZalzMxMZWZmVrr/yZMn1bJlSx05ckSJiYkVtt96662VPq6yyxH79+/Xzp071bx58yqPdWW/oqIi15xV7Xct999/v5o1a1ZhvTo39r788stKSUlRVFSUunTpooceekjDhw9XmzZtrvnYI0eOqF27dmrQwP3/83Xo0MG1/cp/W7Ro4bpEdEVVr2nDhg3VqlWrCuvff/+9pkyZouXLl1e4h6ioqMjte39//wqvv91uV6tWrWSz2Sqs19c9SYC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qdeXt11e+GjVqZEVERFh9+vSxXn/9ddfbfn/q4MGD1vDhw62IiAjL19fXatmypTVgwABr6dKlbvtt377duu+++yw/Pz+rVatWVlZWlvXGG29YkqwTJ0649ouOjq7w9uYriouLrYyMDOvWW2+1GjVqZDVr1szq1q2b9eqrr1oXL1502/ftt9+2unTpYgUEBFjBwcFWp06drEmTJlnHjx+
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_degree_histogram(L)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## ErdősRényi Random Graph"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"0.23025850929940456"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"n = 10\n",
"p1 = np.log(n) / n\n",
"p1"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"scrolled": true,
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAgQAAAGFCAYAAACCBut2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAABKY0lEQVR4nO3deVxUZcM+8GsAUZQll3JJK40l3HAvS81thlFQEBQVF0g0FBWVHvEjvD/wVcr0IQsVFVQUVFwCFBRkScMUyyVJCUVwezQ1UwshVBY5vz/Gp7dVQGbmnmGu7z98PsM5cy44wzkXM/e5j0ySJAlERERk0IxEByAiIiLxWAiIiIiIhYCIiIhYCIiIiAgsBERERAQWAiIiIgILAREREQEwqc1C1dXVuHXrFiwsLCCT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zV8HbOcCnbwA0xdEpSMi0rg7d+4gJCQEmzZtgo2NDT755BOMHDkSMpnsjwvyeKl2dTl/sxBo0q0M4Jg7UPXw6QO//1U//UMwaQoMSATaOWo7HRGRVp09exYBAQE4fPgw5HI5Vq1aha5du6q+yeOlRtTl/M2PDDTlVgZwxAmoegTVC/vPvevpY1WPVMvd4ohcImrYHBwc8MUXXyA5ORlXr16Fg4MD/Pz8UHxhN4+XOoCFQBMqilVNV5IAVNewcLVquWPuqvWIiBowmUyG0aNHIz8/H//+97+RuncHTL6egOrqavB4KRYLgSZciX36tldNL+7/qlYtfzVOk6mIiHSGqakpAgICkH8gEM0
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"## n: number of nodes and p: probability\n",
"\n",
"ER1 = nx.erdos_renyi_graph(n, 0.1)\n",
"\n",
"pos = nx.circular_layout(ER1)\n",
"nx.draw_networkx(ER1, pos=pos, with_labels=False, node_size=100, node_color='orange')\n",
"nx.is_connected(ER1)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAHHCAYAAABDUnkqAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAzZUlEQVR4nO3de3QUVb728achIcEk3YCYBJIAEZgACkGCYgcVwWBEYMi4vBzGYwILOI4Cgoy3qIjAOBmHQfGCAuMRPGIGBpTLQi6GIKASR+4CRxjxwk0SQKCbRGggqfcPX/rYJgESklSy+X7WqiW1a1fVr3pVpx+rdnU7LMuyBAAAYIh6dhcAAABQlQg3AADAKIQbAABgFMINAAAwCuEGAAAYhXADAACMQrgBAABGIdwAAACjEG4AAIBRCDcAjOZwOPT888/bXQaAGkS4AeqAWbNmyeFw+KfQ0FA1b95cqampevXVV3XixAm7S6wRzz//vBwOh44cOVLm8latWqlfv36XvJ/s7GxNmTLlkrcDwB5BdhcA4OJNmDBB8fHxOnPmjPLz87V69WqNHj1aL730khYvXqxOnTrZXWKtc/LkSQUFVexPXXZ2trZv367Ro0dXT1EAqhXhBqhD+vTpo65du/rnMzMztWrVKvXr10+//e1v9dVXX6lhw4Y1Vo9lWTp16lSN7rOiQkND7S6hwoqKihQWFmZ3GUCdxW0poI7r1auXxo4dqz179mj27NkBy3bu3Km7775bTZo0UWhoqLp27arFixeX2saXX36pHj16qGHDhoqNjdWf/vQnzZw5Uw6HQ99//72/37nbPitWrFDXrl3VsGFDTZ8+XZJ0/PhxjR49WnFxcQoJCVGbNm304osvqqSkJGBfJSUlmjJliq655hqFhoYqKipKDz74oI4dO1b1L45Kj7k5ceKERo8erVatWikkJESRkZHq3bu3Nm3aJEm69dZb9eGHH2rPnj3+24CtWrXyr3/o0CENGTJEUVFRCg0NVWJiot55551S+/3xxx/1wAMPyOl0qlGjRsrIyNDWrVvlcDg0a9Ysf79BgwYpPDxc33zzje68805FRETo/vvvlyR98sknuueee9SiRQuFhIQoLi5Ojz76qE6ePBmwr3Pb2Lt3r/r166fw8HDFxMRo6tSpkqRt27apV69eCgsLU8uWLZWdnV1Fry5QO3HlBjDAAw88oKefflofffSRhg0bJknasWOHunfvrpiYGD311FMKCwvTP//5T6Wlpen999/X7373O0nSgQMH1LNnTzkcDmVmZiosLExvvfWWQkJCytzXrl27NHDgQD344IMaNmyYEhIS9NNPP6lHjx46cOCAHnzwQbVo0ULr1q1TZmamDh48GDB+5cEHH9SsWbM0ePBgPfLII/ruu+/0+uuva/Pmzfrss88UHBx8weM9evRome2/DlJl+cMf/qD58+drxIgR6tChg3788Ud9+umn+uqrr9SlSxc988wz8ng82r9/v15++WVJUnh4uKSfb3Hdeuut2r17t0aMGKH4+HjNmzdPgwYN0vHjxzVq1Ch/Hf3799cXX3yhhx56SO3atdOi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qIiJAkpaWl6YYbbtAf//hH7d69W+3atdPixYv9j7BfzGvarl07tW7dWo899pgOHDggp9Op999/n7EywMWw9VktABfl3KPg56YGDRpY0dHRVu/eva1XXnnF/wjyr33zzTdWenq6FR0dbQUHB1sxMTFWv379rPnz5wf027x5s3XzzTdbISEhVmxsrJWVlWW9+uqrliQrPz/f369ly5alHrU+58SJE1ZmZqbVpk0bq0GDBlbTpk2t5ORk629/+5t1+vTpgL4zZsywkpKSrIYNG1o
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_degree_histogram(ER1)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAgQAAAGFCAYAAACCBut2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAADiGklEQVR4nOyddVgU6/vGn91l6S4REUVERbAQbMFOMMHuOordXcfuRuzujmNgd3d3oiKiSNfO/fvD7+4PZBc2ZnYXnc91eZ3r7M6877PMzDv3vPO8zy0AAOLh4eHh4eH5qxHqOgAeHh4eHh4e3cMLAh4eHh4eHh5eEPDw8PDw8PDwgoCHh4eHh4eHeEHAw8PDw8PDQ7wg4OHh4eHh4SFeEPDw8PDw8PAQkYEyGzEMQ58+fSILCwsSCARcx8TDw8PDw8PDAgAoPj6enJ2dSSjMeQ5AKUHw6dMnKliwICvB8fDw8PDw8GiXDx8+kIuLS47bKCUILCwsZA1aWlpqHhkPDw8PDw8P58TFxVHBggVl9/GcUEoQSF8TWFpa8oKAh4eHh4cnj6HM634+qZCHh4eHh4eHFwQ8PDw8PDw8vCDg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5PT0+EhoZi165d+Pr1q9biiYuLg6+vLxwdHbNM58fHx8PCwgLjxo1TuC/DMChevDhat26d5fNVq1aBiDB+/Hi5+3369AndunWDQCBAyZIlcezYMXZ+DA+PhvCCgOeP5PHjx2jYsCGICAEBATkm+s2fPx9EhNmzZ2f5/NOnTzAwMMDixYuzfP67IHj37h2EQiHCw8OzbPd7gpou+PTpE7Zu3YqePXuiaNGishtwmTJlMGjQIBw4cAA/fvzgrP8fP37
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ER2 = nx.erdos_renyi_graph(10, 0.6) \n",
"\n",
"pos = nx.circular_layout(ER1)\n",
"nx.draw_networkx(ER2, pos=pos, with_labels=False, node_size=100, node_color='orange')\n",
"nx.is_connected(ER2)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAHHCAYAAABDUnkqAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAx0ElEQVR4nO3deVxV1f7/8fdREQwBNQUcEFELZxwzsHJIIlOTepRerzfQ1K/XnL0NUtdMzai8lg3mUDftm3I1zelhDiFmVtJ1nvqmpZUj4AyCigr790c/z+1cQAGBDcvX8/HYjzxrr7335yyJ83bvtfdxWJZlCQAAwBDl7C4AAACgKBFuAACAUQg3AADAKIQbAABgFMINAAAwCuEGAAAYhXADAACMQrgBAABGIdwAAACjEG4AGM3hcOiVV16xuwwAJYhwA5QB8+bNk8PhcC4eHh6qVauWIiIi9O677+rChQt2l1giXnnlFTkcDp0+fTrX9fXq1VOPHj1u+ThxcXGaPn36Le8HgD0q2F0AgPybNGmSgoKCdPXqVSUnJ2vjxo0aPXq03nrrLa1cuVItWrSwu8RS59KlS6pQoWC/6uLi4rRv3z6NHj26eIoCUKwIN0AZ0q1bN7Vt29b5OiYmRhs2bFCPHj306KOP6scff1SlSpVKrB7LsnT58uUSPWZBeXh42F1CgWVkZMjT09PuMoAyi8tSQBnXpUsXjR8/XocPH9b8+fNd1u3fv19PPPGEqlWrJg8PD7Vt21YrV67MsY89e/aoY8eOqlSpkurUqaNXX31Vc+fOlcPh0G+//ebsd/2yz7p169S2bVtVqlRJs2fPliSdP39eo0ePVkBAgNzd3dWwYUO98cYbys7OdjlWdna2pk+frqZNm8rDw0N+fn4aMmSIzp07V/SDo5xzbi5cuKDRo0erXr16cnd3l6+vr8LDw7Vjxw5JUqdOnfTFF1/o8OHDzsuA9erVc25/8uRJDRw4UH5+fvLw8FBISIg++eSTHMc9c+aMnnrqKXl7e6tKlSqKjo7W7t275XA4NG/ePGe//v37q3Llyjp06JAeeeQReXl5qV+/fpKkb775Rk8++aTq1q0rd3d3BQQEaMyYMbp06ZLLsa7v48iRI+rRo4cqV66s2rVra8aMGZKkvXv3qkuXLvL09FRgYKDi4uKKaHSB0okzN4ABnnrqKb344ov68ssvNXjwYEnSDz/8oA4dOqh27doaN26cPD099dlnnykyMlKff/65HnvsMUnS8ePH1blzZzkcDsXExMjT01MfffSR3N3dcz3WgQMH1LdvXw0ZMkSDBw9WcHCwLl68qI4dO+r48eMaMmSI6tatq82bNysmJkZJSUku81eGDBmiefPmacCAARo5cqR+/fVXvf/++9q5c6e+++47ubm53fT9nj17Ntf2/w5SufnrX/+qJUuWaPjw4WrSpInOnDmjb7/9Vj/++KNat26tl156SampqTp27JjefvttSVLlypUl/X6Jq1OnTjp48KCGDx+uoKAgLV68WP3799f58+c1atQoZx09e/bUli1bNHToUDVq1EgrVqxQdHR0rjVdu3ZNERERuu+++/SPf/xDd9xxhyRp8eLFunjxooYOHao777xTW7Zs0Xvvvadjx45p8eLFLvvIyspSt27d9MADD+jNN9/UggULNHz4cHl6euqll15Sv3799Pjjj2vWrFmKiopSaGiogoKCbjpeQJlkASj15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WzZMn355ZeaOnWq3njjDS1dulTdunUr9uPnxt3dPUdgysrKUnh4uM6ePasXXnhBjRo1kqenp44fP67+/fvnmF9Uvnz5XPedV7tlWUVTPFAKEW4AA3z66aeS5Awy189CuLm5qWvXrjfcNjAwUAcPHszRnltbXho0aKD09PSbHqtBgwZav369OnToYOvt4zVr1tQzzzyjZ555RidPnlTr1q01ZcoUZ7j57zMd1wUGBmrPnj3Kzs52CSP79+93rr/+36+++koXL150OXtTkDHdu3evfvrpJ33yySeKiopytsfHx+f/jQK3KebcAGXchg0bNHnyZAUFBTnnyfj6+qpTp06aPXu2kpKScmxz6tQp558jIiKUmJioXbt2OdvOnj2b59mV3PTu3VuJiYlat25djnXnz5/XtWvXnP2ysrI0efLkHP2uXbum8+fP5/uYhZGVlZXjco6vr69q1aqlzMxMZ5unp2eOfpL0yCOPKDk5WYsWLXK2Xbt2Te+9954qV66sjh07Svp9TK9evaoPP/zQ2S87O9t5a3Z+XD/j8sczLJZl6Z133sn3PoDbFWdugDJkzZo12r9/v65du6aUlBRt2LBB8fHxCgwM1MqVK13mnMyYMUP33XefmjdvrsGDB6t+/fpKSUlRYmKijh07pt27d0uSnn/+ec2fP1/h4eEaMWKE81bwunXr6uzZs3mexfij5557TitXrlSPHj3Uv39/tWnTRhkZGdq7d6+WLFmi3377TdWrV1fHjh01ZMgQxcbGateuXXrooYfk5uamn3/+WYsXL9Y777yjJ554otjG78KFC6pTp46eeOIJhYSEqHLlylq/fr22bt2qadOmOfu1adNGixYt0tixY9WuXTtVrlxZPXv21P/8z/9o9uzZ6t+/v7Zv36569eppyZIl+u677zR9+nR5eXlJkiIjI3XPPffob3/7mw4ePKhGjRpp5cqVzlvY8zOmjRo1UoMGDfTss8/q+PHj8vb21ueff85cGSA/bL1XC0C+XL8V/PpSsWJFy9/f3woPD7feeecd5y3I/+3QoUNWVFSU5e/vb7m5uVm1a9e2evToYS1ZssSl386dO63777/fcnd3t+rUqWPFxsZa7777riXJSk5OdvYLDAzMcav1dRcuXLBiYmKshg0bWhUrVrSqV69uhYWFWf/4xz+sK1euuPSdM2eO1aZNG6tSpUqWl5eX1bx5c+v555+3Tpw4ccNxuH4r+Kl
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_degree_histogram(ER2)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Small world. Watts-Strogatz (WS) graphs"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAADXCAYAAAAA2rtBAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAACGHElEQVR4nO2ddVxUWRvHfzOAdAmoqAiiYsfagYFKiIliKyrYhYq9umvt6q4iJjZ2IQYqiNgda7sWFqEYgEjnzPP+wTusyMSdYgbmfj+f9+O795545twfZ5459znP4RARgYWFhYWFhYWlFMJVtQEsLCwsLCwsLLLCOjIsLCwsLCwspRbWkWFhYWFhYWEptbCODAsLCwsLC0uphXVkWFhYWFhYWEotrCPDwsLCwsLCUmphHRkWFhYWFhaWUgvryLCwsLCwsLCUWlhHhoWFhYWFhaXUwjoyLCwsLCwsLKUW1pFRMd+/f8fYsWNhZWUFQ0NDODk54cGDB4zrv3jxAm5ubjAyMkL58uUxfPhwJCQkKNFiFhbFIY/+7969i4kTJ6JZs2bQ0dEBh8NRsrUsLIrh06dPmDt3LpycnGBsbAwOh4PLly9L1cbHjx8xYMAAmJmZwcTEBL1798a7d++UY7Caw2HPWlIdfD4f7du3x+PHjzFr1ixYWloiMDAQcXFxuH//PmrVqiW2/ocPH/DLL7/A1NQUU6dORXp6OlatWoVq1arh7t27KFeuXAl9EhYW6ZF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hKSm0tAq0KSZWgNU+S5mF1b9awjoyUpKSkoKtW7fCIjkDw7u4QUd
"text/plain": [
"<Figure size 700x225 with 3 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(7, 2.25))\n",
"for i, p in enumerate([0.0, 0.1, 1.0]):\n",
" # Generate the graph: n: number of nodes; k: neighbours, p: prob of rewiring an edge\n",
" G = nx.watts_strogatz_graph(8, 4, p)\n",
" # Create layout and draw\n",
" plt.subplot(1, 3, i + 1)\n",
" pos = nx.circular_layout(G)\n",
" nx.draw_networkx(G, pos=pos, node_color='pink')\n",
" plt.title(\"p = {:0.1f}\".format(p))"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAHHCAYAAABDUnkqAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAwj0lEQVR4nO3deVxV9b7/8fdWEYxhqymggorZwSHFMUMrh0AyNalH6fV4A73q7ZiY5mmiMtMGKo9lgznUTbopV9NyeJhDiKmVeHKebnrSyhFwBiFBhfX7o5/7tgNUEFjw7fV8PNYj93d911qfvZcP97vv+q61HZZlWQIAADBENbsLAAAAKEuEGwAAYBTCDQAAMArhBgAAGIVwAwAAjEK4AQAARiHcAAAAoxBuAACAUQg3AADAKIQbAEZzOBx66aWX7C4DQAUi3ABVQGJiohwOh2vx8vJSw4YNFRUVpXfffVfnz5+3u8QK8dJLL8nhcOjUqVNFrm/atKn69et3w8dJSkrStGnTbng/AOxRw+4CAFy/yZMnKyQkRJcuXVJ6errWrVuncePG6a233tKyZcvUtm1bu0usdC5cuKAaNUr2T11SUpL27NmjcePGlU9RAMoV4QaoQvr06aNOnTq5XsfHx2vt2rXq16+f7r//fv3www+qVatWhdVjWZZyc3Mr9Jgl5eXlZXcJJZaTkyNvb2+7ywCqLC5LAVVcr169NGHCBB06dEhz5851W7dv3z499NBDqlu3rry8vNSpUyctW7as0D527dql7t27q1atWgoKCtIrr7yiOXPmyOFw6JdffnH1u3LZZ/Xq1erUqZNq1aqlWbNmSZLOnTuncePGKTg4WJ6enmrevLneeOMNFRQUuB2roKBA06ZNU+vWreXl5aWAgAA9+uijOnv2bNl/OCo85+b8+fMaN26cmjZtKk9PT/n7+ysyMlLbtm2TJPXo0UNffvmlDh065LoM2LRpU9f2J06c0PDhwxUQECAvLy+FhYXpk08+KXTc06dP65FHHpGfn59q166t2NhY7dy5Uw6HQ4mJia5+Q4cOlY+Pjw4ePKj77rtPvr6+GjJkiCTpm2++0cMPP6zGjRvL09NTwcHBeuKJJ3ThwgW3Y13Zx+HDh9WvXz/5+PioUaNGmj59uiRp9+7d6tWrl7y9vdWkSRMlJSWV0acLVE6M3AAGeOSRR/Tcc8/pq6++0siRIyVJe/fuVbdu3dSoUSM9++yz8vb21meffabo6Gh9/vnneuCBByRJx44dU8+ePeVwOBQfHy9vb2999NFH8vT0LPJY+/fv1+DBg/Xoo49q5MiRCg0N1a+//qru3bvr2LFjevTRR9W4cWNt3LhR8fHxSktLc5u/8uijjyoxMVHDhg3T448/rp9//lnvv/++tm/fru+++04eHh7XfL9nzpwpsv2PQaoof/vb37Ro0SLFxcWpVatWOn36tL799lv98MMP6tChg55//nllZmbq6NGjevvttyVJPj4+kn67xNWjRw8dOHBAcXFxCgkJ0cKFCzV06FCdO3dOY8eOddXRv39/ff/99xo1apRatGihpUuXKjY2tsiaLl++rKioKN155536xz/+oZtuukmStHDhQv36668aNWqUbr75Zn3//fd67733dPToUS1cuNBtH/n5+erTp4/uvvtuvfnmm5o3b57i4uLk7e2t559/XkOGDNGDDz6omTNnKiYmRuHh4QoJCbnm5wVUSRaASm/OnDmWJGvz5s3F9nE6nVb79u1dr++55x6rTZs2Vm5urqutoKDA6tq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pZs6ZVr149q2vXrtY//vEP6+LFi259Z8+ebXXs2NGqVauW5evra7Vp08Z6+umnreP
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_degree_histogram(G)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Barabasi-Albert Model"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAgMAAAGFCAYAAABg2vAPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAB5rklEQVR4nO3dd3gU1dfA8e8mkEIaIQRIaAGSgITei5TQlKoCCiLNQrGACCiKqPywIIIKgqBYEAQpCr6K0jWRIl16R0kCJLQQ0vvu+8ckIZtsz27ans/z8AA7d+5MIJk5c+fcc1UajUaDEEIIIeyWQ0mfgBBCCCFKlgQDQgghhJ2TYEAIIYSwcxIMCCGEEHZOggEhhBDCzkkwIIQQQtg5CQaEEEIIO1fBlEZqtZro6Gg8PDxQqVS2PichhBBCWIFGoyExMRF/f38cHPQ//5sUDERHR1O7dm2rnZwQQgghis/Vq1epVauW3u0mBQMeHh55nXl6elrnzIQQQghhUwkJCdSuXTvvPq6PScFA7qsBT09PCQaEEEKIMsbYK35JIBRCCCHsnAQDQgghhJ2TYEAIIYSwcxIMCCGEEHZOggEhhBDCzkkwIIQQQtg5CQaEEEIIOyfBgBBCCGHnJBgQQggh7JwEA0IIIYSdk2BACCGEsHMSDAghhBB2ToIBIYQQws5JMCCEEELYOQkGhBBCCDsnwYAQQghh5yqU9AkIIYQoxbKzITUd1GpwcABXZ3B0LOmzElYmwYAQQghtyakQcxti4yEtvfB2F2fw8QI/X3BzLf7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byYNGZlVoNBpu3r1LSL36gFJr4dD5M7zwyFB
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"G_preferential_35 = nx.barabasi_albert_graph(35, 1)\n",
"pos = nx.spring_layout(G_preferential_35, k=0.1)\n",
"nx.draw_networkx(G_preferential_35, pos, node_color='pink')"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAHHCAYAAACle7JuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAs80lEQVR4nO3de1RVdf7/8dcREIjLIVRuooiX0EwptPyilnlFS7+pU5bjJDjpOAYWmVnUz9QsmWpqrMbU6pu2TNPRspwmNe/dLC/lrUkT867gLa4qKuzfHy3PikAFBPb50POx1ll59tlnn/c+ueLZPntzHJZlWQIAADBQHbsHAAAAqCxCBgAAGIuQAQAAxiJkAACAsQgZAABgLEIGAAAYi5ABAADGImQAAICxCBkAAGAsQgZAreJwODRx4kS7xwBQQwgZwA3Nnj1bDofDdfPx8VFERIQSEhL06quvKi8vz+4Ra8TEiRPlcDh04sSJMh9v0qSJ+vbte9WvM2/ePE2dOvWqtwOg5nnaPQCAS3vmmWcUHR2t8+fPKzMzU2vXrlVqaqpefvllLVmyRG3btrV7RLdz5swZeXpW7D9t8+bN044dO5Samlo9QwGoNoQM4Mb69Omj9u3bu+6npaVp9erV6tu3r/73f/9XP/zwg3x9fWtsHsuydPbs2Rp9zYry8fGxe4QKKygokJ+fn91jAEbioyXAMN26ddP48eO1f/9+vfvuuyUe27lzp+6++24FBwfLx8dH7du315IlS0ptY9u2berSpYt8fX0VGRmpZ599VrNmzZLD4dC+fftc61386Gb58uVq3769fH19NX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xQx44dU1xcnJ577jlXyPz2CMZFUVFR2rZtm4qLi0uEx86dO12PX/znmjVrdPr06RJHZSrynm7fvl0//vij3nnnHQ0dOtS1fMWKFeXfUeB3iHNkAMOsXr1akydPVnR0tOu8lpCQEN1+++2aOXOmjh49Wuo5x48fd/05ISFB69ev15YtW1zLTp06dcmjJmUZNGiQ1q9fr+XLl5d6LDs7WxcuXHCtV1RUpMmTJ5da78KFC8rOzi73a1ZGUVFRqY9kQkJCFBERocLCQtcyPz+/UutJ0h133KHMzEwtWLDAtezChQt67bXX5O/vry5dukj65T09f/683nzzTdd6xcXFrsuhy+PikZRfHzmxLEuvvPJKubcB/B5xRAZwY0uXLtXOnTt14cIFZWVlafXq1VqxYoWioqK0ZMmSEueITJs2TZ07d1abNm00YsQINW3aVFlZWVq/fr0OHTqkrVu3SpLGjRund999Vz179tTo0aNdl183btxYp06duuTRiV977LHHtGTJEvXt21dJSUlq166dCgoKtH37di1atEj79u1T/fr11aVLF40cOVLp6enasmWLevXqJS8vL+3evVsLFy7UK6+8orvvvrva3r+8vDxFRkbq7rvvVmxsrPz9/bVy5Upt3LhRL730kmu9du3aacGCBRozZoxuvvlm+fv7q1+/fvrLX/6imTNnKikpSZs3b1aTJk20aNEiffnll5o6daoCAgIkSf3799ctt9yiRx99VBkZGWrZsqWWLFniumy8PO9py5Yt1axZM40dO1aHDx9WYGCg3n//fc5tAa7E1mumAJTp4uXXF29169a1wsLCrJ49e1qvvPKK67Lf39qzZ481dOhQKywszPLy8rIaNmxo9e3b11q0aFGJ9b777jvr1ltvtby9va3IyEgrPT3devXVVy1JVmZmpmu9qKioUpc3X5SXl2elpaVZzZs3t+rWrWvVr1/f6tixo/X3v//dOnfuXIl133jjDatdu3aWr6+vFRAQYLVp08YaN26cdeTIkcu
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_degree_histogram(G_preferential_35)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Example Barabasi"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"# n = 1000 nodes and m = 2 minimum degree\n",
"BA = nx.barabasi_albert_graph(1000, 2)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmsAAAJrCAYAAAC/TNTkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOyddXhTZxuH70jdsaLFStFCKe4uw53h7ozBcB+MYUM2hrsz3BkOBVqktEhxqkihtEBdk5zvj7RZSy3FVva993VxAcmRN2ma8zuP/B6ZJEkSAoFAIBAIBIJsifzfXoBAIBAIBAKBIH2EWBMIBAKBQCDIxgixJhAIBAKBQJCNEWJNIBAIBAKBIBsjxJpAIBAIBAJBNkaINYFAIBAIBIJsjBBrAoFAIBAIBNkYIdYEAoFAIBAIsjFCrAkEAoFAIBBkY4RYEwgEAoFAIMjGCLEmEAgEAoFAkI0RYk0gEAgEAoEgGyPEmkAgEAgEAkE2Rog1gUAgEAgEgmyMEGsCgUAgEAgE2Rgh1gQCgUAgEAiyMUKsCQQCgUAgEGRjhFgTCAQCgUAgyMYIsSYQCAQCgUCQjRFiTSAQCAQCgSAbI8SaQCAQCAQCQTZGiDWBQCAQCASCbIwQawKBQCAQCATZGCHWBAKBQCAQCLIxQqwJBAKBQCAQZGOEWBMIBAKBQCDIxgixJhAIBAKBQJCNEWJNIBAIBAKBIBsjxJpAIBAIBAJBNkaINYFAIBAIBIJsjBBrAoFAIBAIBNkYIdYEAoFAIBAIsjFCrAkEAoFAIBBkY4RYEwgEAoFAIMjGCLEmEAg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"text/plain": [
"<Figure size 600x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pos = nx.spring_layout(BA)\n",
"plt.figure(figsize=(6,6))\n",
"nx.draw(BA, pos, node_color='c', node_size=60, with_labels=False)\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"1000"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# number of nodes\n",
"BA.order()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
"text/plain": [
"1996"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# number of edges´plt.bar(deg, cnt, width=0.80, color='b')\n",
"BA.size()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
"text/plain": [
"3.992"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# average degree\n",
"2*BA.number_of_edges() / float(BA.number_of_nodes())"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[(2, 90), (5, 86), (4, 68), (0, 60), (7, 33), (10, 32), (29, 30), (9, 27)]"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## Sorted nodes by degree\n",
"sorted(BA.degree, key=lambda x: x[1], reverse=True)[0:8]"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# node with the largest degree\n",
"node_highest_degree, degree = sorted(BA.degree, key=lambda x: x[1], reverse=True)[0]\n",
"node_highest_degree"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[3, 4, 6, 7, 11, 13, 14, 17, 23]"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# neighbors\n",
"list(BA.neighbors(node_highest_degree))[1:10]"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"### Ego network\n",
"EGO_HIGHEST = nx.ego_graph(BA, node_highest_degree)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmsAAAJrCAYAAAC/TNTkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzddViUWfsH8O8zQXcoSgguthiIitiJ3YW5dnfn6pprd71rYLeuogIKuIKKLMrahYCuiIFB58z9+0Pn+YHMMMGAqOdzXXtd78s8z3kOODo359znvjkiIjAMwzAMwzDFkuBbT4BhGIZhGIZRjAVrDMMwDMMwxRgL1hiGYRiGYYoxFqwxDMMwDMMUYyxYYxiGYRiGKcZYsMYwDMMwDFOMsWCNYRiGYRimGGPBGsMwDMMwTDHGgjWGYRiGYZhijAVrDMMwDMMwxRgL1hiGYRiGYYoxFqwxDMMwDMMUYyxYYxiGYRiGKcZYsMYwDMMwDFOMsWCNYRiGYRimGGPBGsMwDMMwTDHGgjWGYRiGYZhijAVrDMMwDMMwxRgL1hiGYRiGYYoxFqwxDMMwDMMUYyxYYxiGYRiGKcZYsMYwDMMwDFOMsWCNYRiGYRimGGPBGsMwDMMwTDHGgjWGYRiGYZhijAVrD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GYbSBBWsM85XRo0ejRo0aGDVqFCRKqsIrU5QnNf39/WFpaYmaNWvyX+vRowekUilOnDih8bhM8XT9+nUkJyejdevWuHnzJt68eaN2vhoRwdvbG507d4apqWkhzZRhmIJiwRrDfEUkEmHr1q2IiIjAli1bCjRWUZ7U9PPzQ8uWLSEU/v/TSpY
"text/plain": [
"<Figure size 600x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Draw ego_network\n",
"os = nx.spring_layout(EGO_HIGHEST)\n",
"plt.figure(figsize=(6,6))\n",
"nx.draw(EGO_HIGHEST, pos, node_color='c', node_size=60)\n",
"nx.draw_networkx_nodes(EGO_HIGHEST, pos, nodelist=[node_highest_degree], node_size=100, node_color=\"r\")\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAHHCAYAAACle7JuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAxb0lEQVR4nO3df3zN9f//8fvBbGs/zsyP/WBYkkkolA5KNC1FRKne3hlFPjVqVLJ3b7+SVipJb6Jf9CnrB6X0A29NCS2x/OwdIfm9+blztmnD9vr+0cf5vk+bbLM556nb9XJ5XXg9n8/zfD3Ocbl07r1ez9fr2CzLsgQAAGCgat4uAAAAoKIIMgAAwFgEGQAAYCyCDAAAMBZBBgAAGIsgAwAAjEWQAQAAxiLIAAAAYxFkAACAsQgyAC4oNptN48eP93YZAM4Tggzgg+bMmSObzebeAgICFB0drYSEBE2bNk25ubneLvG8GD9+vGw2mw4fPlxqf+PGjdWjR49zPk5aWpqmTp16zvMAOP9qeLsAAGf25JNPKjY2VidPnlRWVpa+/vprJScna8qUKVq4cKFatWrl7RJ9zm+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HQ7GxsWf9vADjWAB8zuzZsy1J1po1a844xm63W1deeaV7/4YbbrBatmxpFRQUuNuKi4utDh06WE2bNnW3DR8+3LLZbNa6devcbUeOHLHCw8MtSdbOnTvd7Y0aNbIkWYsXL/Y49sSJE62goCDr559/9mgfPXq0Vb16dWv37t2WZVnWihUrLEnW3LlzPcYtXry41PY/GjdunCXpT7dbbrnF4zWSrHHjxnl8TklJSX96nFtuucVq1KhRifapU6dakqx33nnH3XbixAnL4XBYwcHBlsvlsizLsj788ENLkjV16lT3uKKiIqtr166WJGv27Nnu9sTEREuSNXr06BLHO378eIm21NRUy2azWbt27Soxx9NPP+1uO3bsmBUYGGjZbDbrvffec7dv2bKlxGcCXEi4tAQYKjg42H330tGjR7Vs2TL169dPubm5Onz4sA4fPqwjR44oISFB27Zt0759+yRJixcvlsPh0BVXXOGeKzw83H15449iY2OVkJDg0TZv3jxde+21qlWrlvtYhw8fVnx8vIqKivTNN9+4x9ntdnXr1s1jXNu2bRUcHKyvvvqqTO/1ww8/1NKlS0tsERERZ31tWFiYVq9erf3795fpWP/tiy++UGRkpO6++253m5+fnx566CHl5eVp+fLlkn7/TP38/NxnxySpWrVqSkpKOuPcDzzwQIm2/157lJ+fr8OHD6tDhw6yLEvr1q0rMX7w4MHuv4eFhalZs2YKCgpSv3793O3NmjVTWFiYfvnllzK+a8AsXFoCDJWXl6d69epJkrZv3y7LsjRmzBiNGTOm1PEHDx5U/fr1tWvXLjkcjhL9l1xySamvK+1yxLZt27Rx40bVrVv3jMc6Pc7pdLrrPNO4s7nuuutUp06dEu1lWdg7efJkJSYmKiYmRm3bttXNN9+sAQMG6OKLLz7ra3ft2qWmTZuqWjXP/+dr3ry5u//0n1FRUe5LRKed6TOtUaOGGjRoUKJ99+7dGjt2rBYuXFhiDZHT6fTYDwgIKPH52+12NWjQQDabrUR7Va1JAryNIAMYaO/evXI6ne4vytNrRR599NESZ09OO9OX6tmUdodScXGxunXrplGjRpX6mksvvdQ9rl69epo7d26p484UhCpTv379dO2112rBggX697//reeee07PPvusPvroI3Xv3r3Kj18af3//EuGoqKhI3bp109GjR/X4448rLi5OQUFB2rdvnwYOHFhiPVD16tVLnftM7ZZlVU7xgI8hyAAGevvttyXJHVpOn13w8/NTfHz8n762UaNG2r59e4n20trOpEmTJsrLyzvrsZo0aaIvv/xSHTt29Oot21FRUXrwwQf14IMP6uDBg2rTpo0mTZrkDjJ/PINxWqNGjbRx40YVFxd7BI8tW7a4+0//+dVXX+n48eMeZ2XK85lu2rRJP//8s9566y0NGDDA3b506dKyv1HgL4g1MoBhli1bpokTJyo2Nta9rqVevXq6/vrrNWvWLB04cKDEaw4dOuT+e0JCgjIyMrR+/Xp329GjR8941qQ0/fr1U0ZGhpYsWVKiLycnR6dOnXKPKyoq0sSJE0uMO3XqlHJycsp8zIooKioqcUmmXr16io6OVmFhobstKCioxDhJuvnmm5WVlaX333/f3Xbq1Cm9/PLLCg4OVufOnSX9/pmePHlSr732mntccXGx+3bosjh9JuW/z5xYlqWXXnqpzHMAf0WckQF82KJFi7RlyxadOnVK2dnZWrZsmZYuXapGjRpp4cKFHmtEpk+frk6dOqlly5YaMmSILr74YmVnZysjI0N79+7Vhg0bJEmjRo3SO++8o27dumn48OHu268bNmyoo0ePnvHsxH977LHHtHDhQvXo0UMDBw5U27ZtlZ+fr02bNmn+/Pn69ddfVadOHXXu3FlDhw5Vamqq1q9frxtvvFF+fn7atm2b5s2bp5deekm33357lX1+ubm5atCggW6//Xa1bt1awcHB+vLLL7VmzRq98MIL7nFt27bV+++/r5EjR+qqq65ScHCwevbsqfvvv1+zZs3SwIEDlZmZqcaNG2v+/PlatWqVpk6dqpCQEElS7969dfXVV+uRRx7R9u3bFRcXp4ULF7pvGy/LZxoXF6cmTZro0Ucf1b59+xQaGqoPP/yQtS3A2Xj1nikApTp9+/XprWbNmlZkZKTVrVs366WXXnLf9vtHO3bssAYMGGBFRkZafn5+Vv369a0ePXpY8+fP9xi3bt0669prr7X8/f2tBg0aWKmpqda0adMsSVZWVpZ7XKNGjUrc3nxabm6ulZKSYl1yySVWzZo1rTp16lgdOnSwnn/+eevEiRMeY1999VWrbdu2VmBgoBUSEmK1bNnSGjVqlLV///4//Rx
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot_degree_histogram(EGO_HIGHEST)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmsAAAJrCAYAAAC/TNTkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8fJSN1AAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOyddXhTZxuH70jdsaLFStFCKe4uw53h7ozBcB+MYUM2hrsz3BkOBVqktEhxqkihtEBdk5zvj7RZSy3FVva993VxAcmRN2ma8zuP/B6ZJEkSAoFAIBAIBIJsifzfXoBAIBAIBAKBIH2EWBMIBAKBQCDIxgixJhAIBAKBQJCNEWJNIBAIBAKBIBsjxJpAIBAIBAJBNkaINYFAIBAIBIJsjBBrAoFAIBAIBNkYIdYEAoFAIBAIsjFCrAkEAoFAIBBkY4RYEwgEAoFAIMjGCLEmEAgEAoFAkI0RYk0gEAgEAoEgGyPEmkAgEAgEAkE2Rog1gUAgEAgEgmyMEGsCgUAgEAgE2Rgh1gQCgUAgEAiyMUKsCQQCgUAgEGRjhFgTCAQCgUAgyMYIsSYQCAQCgUCQjRFiTSAQCAQCgSAbI8SaQCAQCAQCQTZGiDWBQCAQCASCbIwQawKBQCAQCATZGCHWBAKBQCAQCLIxQqwJBAKBQCAQZGOEWBMIBAKBQCDIxgixJhAIBAKBQJCNEWJNIBAIBAKBIBsjxJpAIBAIBAJBNkaINYFAIBAIBIJsjBBrAoFAIBAIBNkYIdYEAoFAIBAIsjFCrAkEAoFA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9WvGjx+fZZuM6Oho2rZty9mzZzl
"text/plain": [
"<Figure size 600x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"## Ego network 2 hops\n",
"EGO_HIGHEST_2 = nx.ego_graph(BA, node_highest_degree, radius=4)\n",
"os = nx.spring_layout(EGO_HIGHEST_2)\n",
"plt.figure(figsize=(6,6))\n",
"nx.draw(EGO_HIGHEST_2, pos, node_color='c', node_size=60)\n",
"nx.draw_networkx_nodes(EGO_HIGHEST_2, pos, nodelist=[node_highest_degree], node_size=100, node_color=\"r\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"## Licence"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n",
"© Carlos A. Iglesias, Universidad Politécnica de Madrid."
]
}
],
"metadata": {
"celltoolbar": "Slideshow",
"datacleaner": {
"position": {
"top": "50px"
},
"python": {
"varRefreshCmd": "try:\n print(_datacleaner.dataframe_metadata())\nexcept:\n print([])"
},
"window_display": false
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.7"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}