{"id":23451402,"url":"https://github.com/coloquinte/roulette","last_synced_at":"2025-08-10T22:32:52.699Z","repository":{"id":81171255,"uuid":"105064063","full_name":"Coloquinte/Roulette","owner":"Coloquinte","description":"Weighted random selection","archived":false,"fork":false,"pushed_at":"2017-09-28T20:48:27.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-03T11:54:48.499Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Coloquinte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-27T20:06:49.000Z","updated_at":"2019-04-06T08:21:58.000Z","dependencies_parsed_at":"2023-03-08T23:30:54.444Z","dependency_job_id":null,"html_url":"https://github.com/Coloquinte/Roulette","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Coloquinte/Roulette","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coloquinte%2FRoulette","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coloquinte%2FRoulette/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coloquinte%2FRoulette/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coloquinte%2FRoulette/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Coloquinte","download_url":"https://codeload.github.com/Coloquinte/Roulette/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Coloquinte%2FRoulette/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269799286,"owners_count":24477630,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-12-24T00:25:55.426Z","updated_at":"2025-08-10T22:32:52.680Z","avatar_url":"https://github.com/Coloquinte.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Roulette tree\n\nRandom weighted selection, dynamic: select an element with probability proportional to its weight.\n\nIt is an important step in many randomized algorithms. This datastructure provides efficient update and query (O(log n)).\n\nIt is inspired by a [pointer-based implementation](https://github.com/hyPiRion/roulette-tree).\nCompared to it, it will have much lower memory usage (~3x), and may have better performance (not benchmarked).\n\nIt is still a work in progress, and will still be improved over time.\n\n## Implementation\n\nThe datastructure is a balanced binary tree with the elements as leaves. Each node stores the total weight of its subtree.\nThe selection procedure rolls a number between 0 and the sum of the weights, and the corresponding element is obtained by dichotomy.\n\nLike a typical binary heap, the tree is stored in an array and doesn't have to use any pointer: the datastructure uses contiguous memory space for at most 3n weights.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoloquinte%2Froulette","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoloquinte%2Froulette","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoloquinte%2Froulette/lists"}