{"id":22799336,"url":"https://github.com/shiritai/rooted-disjoint-set","last_synced_at":"2025-03-30T19:15:39.789Z","repository":{"id":263355603,"uuid":"890118853","full_name":"Shiritai/rooted-disjoint-set","owner":"Shiritai","description":"Python implementation of a (rooted) disjoint set, elegant, efficient and user-friendly.","archived":false,"fork":false,"pushed_at":"2024-11-18T02:44:16.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T21:44:00.782Z","etag":null,"topics":["algorithm","data-structure","disjoint-set","disjoint-set-union","python","python-dict","union-find"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Shiritai.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":"2024-11-18T02:42:05.000Z","updated_at":"2024-11-18T02:54:27.000Z","dependencies_parsed_at":"2024-11-18T09:10:37.966Z","dependency_job_id":null,"html_url":"https://github.com/Shiritai/rooted-disjoint-set","commit_stats":null,"previous_names":["shiritai/rooted-disjoint-set"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shiritai%2Frooted-disjoint-set","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shiritai%2Frooted-disjoint-set/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shiritai%2Frooted-disjoint-set/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shiritai%2Frooted-disjoint-set/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shiritai","download_url":"https://codeload.github.com/Shiritai/rooted-disjoint-set/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246365651,"owners_count":20765549,"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":["algorithm","data-structure","disjoint-set","disjoint-set-union","python","python-dict","union-find"],"created_at":"2024-12-12T07:08:41.634Z","updated_at":"2025-03-30T19:15:39.323Z","avatar_url":"https://github.com/Shiritai.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# (Rooted) Disjoint set\n\n\u003e [!NOTE]\n\u003e 可參閱[中文文檔](./README.zh_TW.md)。\n\n\u003e [!IMPORTANT]\n\u003e This is perhaps the most elegant, user-friendly and Python-styled implementation I've ever seen!\n\n## TL;DR\n\nA disjointed set (`dict[key, root_of_key]`) that\n\n* behaves completely the same as a Python `dict`\n    * has `dict` based and `disjoint-set` based methods for accessing\n    * with complete the same effect\n* reserve the root-child relation of the keys\n* optimized with flattening\n\n## Usage\n\n### Instantiate\n\n```python\nds = RootedDisjointSet()\n\n# or\nds = RootedDisjointSet({ 1: 1, 2: 1, 3: 2 })\n# 1 \u003c- 2 \u003c-3\n\n# or\nds = RootedDisjointSet({ 1: '1', '2': '1', 3: 1 })\n# '1' \u003c- 1 \u003c- 3\n# '1' \u003c- '2'\n# note that key can be any hashable type\n```\n\n### Set dependent (Merge)\n\n```python\nds[key] = value\n# or\nds.set_dependent(key, value)\n```\n\n### Find root (Find)\n\n```python\nds[key]\n# or\nds.find_root(key)\n```\n\n### Has same root (Check)\n\n```python\nds[key1] == ds[key2]\n# or\nds.has_same_root(key1, key2)\n```\n\n### Is same disjoint set\n\n```python\nds1 = RootedDisjointSet()\nds2 = RootedDisjointSet()\nds1 == ds2\n```\n\n## Note\n\nWelcome to give any kinds of comment, open issues or make PR ;)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiritai%2Frooted-disjoint-set","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshiritai%2Frooted-disjoint-set","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiritai%2Frooted-disjoint-set/lists"}