{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Activity Driven\n" ], "id": "d6db4934" }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ ".. admonition:: Definition\n", "\n", " Activity-driven temporal hypergraphs activate nodes with rates and create hyperedges at each time step.\n" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ ".. admonition:: You will learn\n", "\n", " Generate temporal activity-driven hypergraphs and inspect their dynamics.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Overview\n", "\n", "- Generate a temporal activity-driven hypergraph from model parameters.\n", "- Inspect the resulting structure and basic statistics.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup\n" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import matplotlib as mpl\n", "\n", "mpl.rcParams.update({\n", " \"figure.figsize\": (6, 4),\n", " \"figure.dpi\": 120,\n", " \"savefig.dpi\": 150,\n", "})\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "from collections import Counter\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "sys.path.append(\"..\")\n", "from hypergraphx.communities.hy_mmsbm.model import HyMMSBM\n", "from hypergraphx.core.temporal_hypergraph import TemporalHypergraph\n", "from hypergraphx.generation.hy_mmsbm_sampling import HyMMSBMSampler\n", "from hypergraphx.linalg.linalg import *\n", "from hypergraphx.dynamics.randwalk import *\n", "from hypergraphx.generation.activity_driven import *\n", "import random" ], "id": "d8e66971" }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def rnd_pwl(xmin, xmax, g, size=1):\n", " r = np.random.random(size=size)\n", " return (r*( xmax**(1.-g) - xmin**(1.-g) ) + xmin**(1.-g) )**(1./(1.-g))\n", "\n", "orders = [1,2,5]\n", "beta_act = 2.25\n", "eps = 0.001\n", "N = 100\n", "activities = rnd_pwl(eps, 1.0, beta_act, N) \n", "activities_per_order = {order: activities for order in orders}" ], "id": "113cd096" }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "HG = HOADmodel(N, activities_per_order, time=100)" ], "id": "df585bba" }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.00122684, 0.0030016 , 0.00115932, 0.00232638, 0.00123835,\n", " 0.00146535, 0.01942779, 0.00155625, 0.00158992, 0.00117872,\n", " 0.00175645, 0.00120718, 0.00166537, 0.0011417 , 0.00111237,\n", " 0.00224994, 0.00124012, 0.00108481, 0.00169755, 0.00108913,\n", " 0.00258711, 0.0018887 , 0.00139368, 0.00207586, 0.00112409,\n", " 0.00202954, 0.00135815, 0.00280731, 0.00119374, 0.00239654,\n", " 0.00145397, 0.00196627, 0.00517187, 0.0019846 , 0.00245724,\n", " 0.00273485, 0.00279709, 0.00210364, 0.00404598, 0.00395033,\n", " 0.00138353, 0.00288704, 0.0037446 , 0.0023175 , 0.00162702,\n", " 0.00100739, 0.00183573, 0.00129032, 0.00234852, 0.00165624,\n", " 0.00150109, 0.00169891, 0.00111026, 0.0017071 , 0.0079329 ,\n", " 0.00201479, 0.00122535, 0.00246889, 0.00207982, 0.00255218,\n", " 0.00500995, 0.00154157, 0.00337264, 0.00143736, 0.00138248,\n", " 0.00147987, 0.00121604, 0.00161813, 0.00101783, 0.00245326,\n", " 0.00224526, 0.0012563 , 0.00116481, 0.00209183, 0.00128031,\n", " 0.00226608, 0.00180236, 0.00105422, 0.00232507, 0.00604522,\n", " 0.00198912, 0.00190691, 0.0033083 , 0.00222755, 0.00118875,\n", " 0.00102142, 0.00129231, 0.00102529, 0.01145748, 0.00485772,\n", " 0.00252576, 0.00178571, 0.00263117, 0.00146426, 0.00157329,\n", " 0.00484214, 0.00192983, 0.00132683, 0.0013145 , 0.00407684])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "activities_per_order[1]" ], "id": "29e5254f" } ], "metadata": { "kernelspec": { "display_name": "hgx-installation", "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.9.17" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 5 }