{"id":20723590,"url":"https://github.com/networks-learning/redqueen","last_synced_at":"2025-04-23T17:27:31.365Z","repository":{"id":150974519,"uuid":"80982913","full_name":"Networks-Learning/RedQueen","owner":"Networks-Learning","description":"Code for \"RedQueen: An Online Algorithm for Smart Broadcasting on Social Networks\", WSDM 2017","archived":false,"fork":false,"pushed_at":"2018-09-03T19:17:59.000Z","size":969,"stargazers_count":20,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T01:51:45.606Z","etag":null,"topics":["broadcasting","online-algorithms","python","redqueen","simulation","smart","social-network","wsdm"],"latest_commit_sha":null,"homepage":"http://learning.mpi-sws.org/redqueen/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Networks-Learning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-02-05T09:32:55.000Z","updated_at":"2025-01-19T12:46:10.000Z","dependencies_parsed_at":"2023-09-24T16:56:44.198Z","dependency_job_id":null,"html_url":"https://github.com/Networks-Learning/RedQueen","commit_stats":{"total_commits":147,"total_committers":4,"mean_commits":36.75,"dds":0.03401360544217691,"last_synced_commit":"f8a3aeda5b7e9e0793914cfef18334650053087e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Networks-Learning%2FRedQueen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Networks-Learning%2FRedQueen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Networks-Learning%2FRedQueen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Networks-Learning%2FRedQueen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Networks-Learning","download_url":"https://codeload.github.com/Networks-Learning/RedQueen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250479615,"owners_count":21437395,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["broadcasting","online-algorithms","python","redqueen","simulation","smart","social-network","wsdm"],"created_at":"2024-11-17T04:09:10.184Z","updated_at":"2025-04-23T17:27:31.350Z","avatar_url":"https://github.com/Networks-Learning.png","language":"Jupyter Notebook","readme":"# RedQueen\n\nThis is a repository containing code for the paper:\n\n\u003e A. Zarezade, U. Upadhyay, H. R. Raibee, M. Gomez-Rodriguez. RedQueen: An Online Algorithm for Smart Broadcasting in Social Networks. In Proceedings of the 10th ACM International Conference on Web Search and Data Mining (WSDM), 2017.\n\n## Pre-requisites\n\nThis code depends on the following packages:\n\n 1. `decorated_options`: Installation instructions are at [musically-ut/decorated_options](https://github.com/musically-ut/decorated_options) or `pip install decorated_options`.\n 2. `broadcast_ref` package (i.e. Karimi et.al.'s method, which is the used as a baseline). Follow the instructions at [Networks-Learning/broadcast_ref](https://github.com/Networks-Learning/broadcast_ref).\n\n\n## Code structure\n\n - `opt_models.py` contains models for various broadcasters and baselines:\n   - `Poisson` (random posting)\n   - `Hawkes` (bursty posting)\n   - `PiecewiseConst` (different rates at different times)\n   - `RealData` (emulates behavior of a real user in our dataset)\n   - `RedQueen` (our proposed algorithm)\n\n - `utils.py` contains common utility functions for metric calculation and plotting.\n - `opt_runs.py` contains functions to execute the simulations.\n\n - `real_data_gen.py` and `read_real_data.py` files deal with conversion of real Twitter data to and from formats helpful for our models.\n\n\n## Execution\n\nThe code execution is detailed in the included IPython notebooks.\n\nAs an example, say if we have the following structure in our network of\nbroadcasters (i.e. sources) and followers (i.e. sinks), with `Source 1` being\nthe broadcaster we control:\n\n```\n   Source 1**      Source 2      Source 3\n    +   +             +                 +\n    |   |             |                 |\n    |   +----------------------------+  |\n    |                 |              |  |\n    |    +------------+-----------+  |  |\n    |    |            |           |  |  |\n   +v----v-+      +---v---+      +v--v--v+\n   |       |      |       |      |       |\n   |       |      |       |      |       |\n   |       |      |       |      |       |\n   |       |      |       |      |       |\n   |       |      |       |      |       |\n   |       |      |       |      |       |\n   +-------+      +-------+      +-------+\n    Sink 1          Sink 2         Sink 3\n```\n\nThis will be represented in the following way:\n\n```python\nsimOpts = SimOpts(\n   src_id = 1,\n   end_time = 100, # When the simulations stop\n   s = { 1: 1.0, 3: 1.0 }, # Weights of followers of source 1\n   q=1.0, # Control parameter for RedQueen\n   sink_ids = [1, 2, 3],\n   other_sources = [\n      ('Poisson2', { 'src_id': 2,\n                    'seed': 42,\n                    'rate': 10\n                  }),\n      ('Hawkes',  { 'src_id': 3,\n                    'seed': 43,\n                    'l_0': 10,\n                    'alpha': 1.0,\n                    'beta': 10.0\n                  })\n   ],\n   edge_list=[(1, 1), (1, 3), \n              (2, 1), (2, 2), (2, 3),\n              (3, 3)]\n);\n```\n\nThese `SimOpts` objects are immutable and can be used to create multiple simulations.\n\nThen to run the simulation, we need to create a simulation `Manager` by instantiating `Source 1`\nto be a kind of broadcaster, or by removing it altogether.\n\n```python\nmanager = simOpts.create_manager_with_opt(seed=101)\n# or \nmanager = simOpts.create_manager_for_wall()\n```\n\nFinally, run the simulation by calling `.run_dynamic`:\n\n```python\nmanager.run_dynamic()\n```\n\nFinally, the list of events can be extracted for further analysis:\n\n```python\ndf = manager.state.get_dataframe()\n```\n\n\nThe file `utils.py` contains some functions which can assist in calculation of\ncertain metrics:\n\n```python\nimport redqueen.utils as U\nperf_1 = U.time_in_top_k(df=df, K=1, sim_opts=simOpts)\nperf_2 = U.average_rank(df=df, sim_opts=simOpts)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworks-learning%2Fredqueen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetworks-learning%2Fredqueen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworks-learning%2Fredqueen/lists"}