{"id":18014464,"url":"https://github.com/l-tchen/findunion","last_synced_at":"2025-08-17T19:32:18.013Z","repository":{"id":80479978,"uuid":"167615936","full_name":"L-TChen/FindUnion","owner":"L-TChen","description":"An imperative implementation of disjoint-set data structure in Haskell","archived":false,"fork":false,"pushed_at":"2019-01-27T20:53:28.000Z","size":8,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T12:23:54.918Z","etag":null,"topics":["data-structures","disjoint-sets","haskell"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","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/L-TChen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-01-25T21:24:26.000Z","updated_at":"2023-10-19T08:28:21.000Z","dependencies_parsed_at":"2023-03-01T05:45:49.466Z","dependency_job_id":null,"html_url":"https://github.com/L-TChen/FindUnion","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/L-TChen/FindUnion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-TChen%2FFindUnion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-TChen%2FFindUnion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-TChen%2FFindUnion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-TChen%2FFindUnion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/L-TChen","download_url":"https://codeload.github.com/L-TChen/FindUnion/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/L-TChen%2FFindUnion/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270898279,"owners_count":24664700,"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-17T02:00:09.016Z","response_time":129,"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":["data-structures","disjoint-sets","haskell"],"created_at":"2024-10-30T04:09:40.212Z","updated_at":"2025-08-17T19:32:17.626Z","avatar_url":"https://github.com/L-TChen.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Find-Union \n\n## An imperative implementation of disjoint-set data structure in Haskell\n\nThis implementation is based on the original [Find-Union\nalgorithm](https://dl.acm.org/citation.cfm?id=321884) by Tarjan. It provides\nthe standard set of imperative operations in `Data.Union.ST`, i.e. `create`,\n`union`, and `find` (also `connected`), and the type of elements can be any\ninstance of the type class\n[`Ix`](https://www.haskell.org/onlinereport/haskell2010/haskellch19.html).\nThe worst-case time complexity of `union` and `find` in `Data.Union.ST` is\n*O(α(n))* where *α(n)* is the inverse Ackermann function. See\n[this](https://en.wikipedia.org/wiki/Disjoint-set_data_structure) Wikipedia\npage for details.\n\nIn addition, it provides a pure interface in `Data.Union` with a creation operation\n```haskell\nbuildDS :: (Ix i) =\u003e Bound i -\u003e [(i, i)] -\u003e Union i [i]\n```\nwhich takes the range of elements and a list of pairs of the same set and\nproduces a table to check if any two elements are of the same set using\n`connected`. This operation constructs the table within the ST monad and\n*rebalance* every element so that its time complexity is *O(n * α(n))*,\npractically linear, where *n* is the length of range and the time complexity of\n`find` and `connected` is only *O(1)*. Unfortunately, I did not implement a\n`union` operation for this pure interface, as any update to a persistent array\ntakes *O(n)* steps in Haskell. \n\nAlternatively, you can also use \n```haskell\nfromList :: (Ix i) =\u003e (i, i) -\u003e [[i]] -\u003e Union i [i]\n```\nto construct a table to look up which takes, again, the range of elements and a\nlist of lists (instead of pairs) of the same set. Any missing element is\nregarded as a singleton set. \n\nTo the best of my understanding, there is currently no\nfunctional/persistent solution to this problem achieving the same time\ncomplexity. If you happen to know how to do it, please let me know. \n\nThis package is *not* going to Hackage for now.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl-tchen%2Ffindunion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fl-tchen%2Ffindunion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl-tchen%2Ffindunion/lists"}