|
13 | 13 | "import numpy as np\n",
|
14 | 14 | "import random\n",
|
15 | 15 | "import networkx as nx\n",
|
16 |
| - "from IPython.display import HTML" |
| 16 | + "from IPython.display import HTML\n", |
| 17 | + "import matplotlib.animation as animation" |
17 | 18 | ]
|
18 | 19 | },
|
19 | 20 | {
|
|
22 | 23 | "metadata": {},
|
23 | 24 | "outputs": [],
|
24 | 25 | "source": [
|
25 |
| - "n = 100\n", |
26 |
| - "is_connected = False\n", |
27 |
| - "while not is_connected:\n", |
28 |
| - " H = xgi.random_hypergraph(n, [0.03, 0.0002, 0.00001])\n", |
29 |
| - " is_connected = xgi.is_connected(H)\n", |
30 |
| - "pos = xgi.barycenter_spring_layout(H)" |
| 26 | + "H = xgi.load_xgi_data(\"diseasome\")\n", |
| 27 | + "H.cleanup()" |
| 28 | + ] |
| 29 | + }, |
| 30 | + { |
| 31 | + "cell_type": "code", |
| 32 | + "execution_count": null, |
| 33 | + "metadata": {}, |
| 34 | + "outputs": [], |
| 35 | + "source": [ |
| 36 | + "xgi.unique_edge_sizes(H)" |
31 | 37 | ]
|
32 | 38 | },
|
33 | 39 | {
|
|
37 | 43 | "outputs": [],
|
38 | 44 | "source": [
|
39 | 45 | "gamma = 0.05\n",
|
40 |
| - "beta2 = 0.1\n", |
41 |
| - "beta3 = 0.05\n", |
42 |
| - "beta4 = 0.01\n", |
43 |
| - "tau = {1: 0, 2: beta2, 3: beta3, 4: beta4}\n", |
| 46 | + "beta = 0.05\n", |
| 47 | + "tau = {i: beta for i in xgi.unique_edge_sizes(H)}\n", |
44 | 48 | "rho = 0.1"
|
45 | 49 | ]
|
46 | 50 | },
|
|
51 | 55 | "outputs": [],
|
52 | 56 | "source": [
|
53 | 57 | "transition_events = hc.discrete_SIR(\n",
|
54 |
| - " H, tau, gamma, tmin=0, tmax=40, dt=1, rho=rho, return_event_data=True\n", |
| 58 | + " H, tau, gamma, tmin=0, dt=1, rho=rho, return_event_data=True\n", |
55 | 59 | ")"
|
56 | 60 | ]
|
57 | 61 | },
|
|
70 | 74 | "metadata": {},
|
71 | 75 | "outputs": [],
|
72 | 76 | "source": [
|
73 |
| - "node_colors = {\"S\": \"green\", \"I\": \"red\", \"R\": \"blue\"}\n", |
74 |
| - "edge_colors = {\"S\": \"green\", \"I\": \"red\", \"R\": \"blue\", \"OFF\": \"grey\"}\n", |
| 77 | + "S_color = \"white\"\n", |
| 78 | + "I_color = 'firebrick'\n", |
| 79 | + "R_color = 'steelblue'\n", |
| 80 | + "\n", |
| 81 | + "node_colors = {\"S\": S_color, \"I\": I_color, \"R\": R_color}\n", |
| 82 | + "edge_colors = {\"S\": S_color, \"I\": I_color, \"R\": R_color, \"OFF\": \"grey\"}\n", |
75 | 83 | "fps = 1\n",
|
76 | 84 | "fig = plt.figure(figsize=(10, 10))\n",
|
77 |
| - "animation = hc.contagion_animation(\n", |
78 |
| - " fig, H, transition_events, pos, node_colors, edge_colors, fps=fps\n", |
| 85 | + "anim = hc.contagion_animation(\n", |
| 86 | + " fig, H, transition_events, pos, node_colors, edge_colors, fps=fps, node_size=10, dyad_lw=1.5\n", |
79 | 87 | ")\n",
|
80 |
| - "HTML(animation.to_jshtml())" |
| 88 | + "# FFwriter = animation.FFMpegWriter(fps=fps)\n", |
| 89 | + "# anim.save('animation.mp4', writer = FFwriter)" |
81 | 90 | ]
|
82 | 91 | },
|
83 | 92 | {
|
84 | 93 | "cell_type": "code",
|
85 | 94 | "execution_count": null,
|
86 | 95 | "metadata": {},
|
87 | 96 | "outputs": [],
|
88 |
| - "source": [] |
| 97 | + "source": [ |
| 98 | + "HTML(anim.to_jshtml())" |
| 99 | + ] |
89 | 100 | }
|
90 | 101 | ],
|
91 | 102 | "metadata": {
|
|
104 | 115 | "name": "python",
|
105 | 116 | "nbconvert_exporter": "python",
|
106 | 117 | "pygments_lexer": "ipython3",
|
107 |
| - "version": "3.10.4" |
| 118 | + "version": "3.10.0" |
108 | 119 | },
|
109 | 120 | "orig_nbformat": 4,
|
110 | 121 | "vscode": {
|
|
0 commit comments