{"id":25067011,"url":"https://github.com/shoyamanishi/redblacktree","last_synced_at":"2025-08-31T14:34:28.941Z","repository":{"id":187800795,"uuid":"292665761","full_name":"ShoYamanishi/RedBlackTree","owner":"ShoYamanishi","description":"A faithful implementation of the red black tree algorithm by Cormen, Leiserson, Rivest, and Stein.","archived":false,"fork":false,"pushed_at":"2020-09-06T16:00:55.000Z","size":276,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-08T20:11:34.410Z","etag":null,"topics":["algorithm","python3","redblack-tree"],"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/ShoYamanishi.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}},"created_at":"2020-09-03T19:49:48.000Z","updated_at":"2020-09-06T16:00:58.000Z","dependencies_parsed_at":"2023-08-12T07:13:16.390Z","dependency_job_id":null,"html_url":"https://github.com/ShoYamanishi/RedBlackTree","commit_stats":null,"previous_names":["shoyamanishi/redblacktree"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ShoYamanishi/RedBlackTree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShoYamanishi%2FRedBlackTree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShoYamanishi%2FRedBlackTree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShoYamanishi%2FRedBlackTree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShoYamanishi%2FRedBlackTree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShoYamanishi","download_url":"https://codeload.github.com/ShoYamanishi/RedBlackTree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShoYamanishi%2FRedBlackTree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272991815,"owners_count":25027498,"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-31T02:00:09.071Z","response_time":79,"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":["algorithm","python3","redblack-tree"],"created_at":"2025-02-06T20:29:02.954Z","updated_at":"2025-08-31T14:34:28.909Z","avatar_url":"https://github.com/ShoYamanishi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLRS Red-Black-Tree Algorithm in Python\n\n\u003ca href=\"sample.png\"\u003e \u003cimg src=\"sample.png\"\u003e\u003c/a\u003e\n\nA python implementation of the Red-black-tree algorithm by Cormen, Leiserson, Rivest, and Stein [CLRS]\n\nI find the description by [CLRS] the most accurate, concise, and easiest to understand.\nThe only two changes I made are the extra checks for NIL parameter in the beginning of LEFT_ and RIGHT_ROTATE().\n\n# Dependencies\n\n* **Graphviz** for drawing trees. Comment out import if you don't need to draw.\n\n# Usage\nSee Chap. 13 \u0026 14 in [CLRS]\n\n* **Create a Tree** ```t = rbtree.RedBlackTree()```\n\n* **Create a Node** ```n = rbtree.RedBlackNode(0.0)```\n\n* **Insert a node to a tree** ```t.RB_INSERT(n)```\n\n* **Remove a node from a tree** ```t.RB_DELETE(n)```\n\n* **Root node** n = ```n = t.ROOT()```\n\n* **Minimum node** n = ```n = t.TREE_MINIMUM(t.ROOT())```\n\n* **Maximum node** n = ```n =  t.TREE_MAXIMUM(t.ROOT())```\n\n* **Iterate ascending**\n\n```python\nfor v in t:\n    print(v)\n```\nor\n```python\nn = t.TREE_MINIMUM(t.ROOT())\nwhile not n is t.NIL():\n    n = t.TREE_SUCCESSOR(n)\n    print(n)\n```\n\n* **Iterate descending**\n\n```python\nn = t.TREE_MAXIMUM(t.ROOT())\nwhile not n is t.NIL():\n    n = t.TREE_PREDECESSOR(n)\n    print(n)\n```\n\n* **draw tree** ```t.draw('filename_wo_ext', True, 'pdf', 'vertical' )```\n\nSee [unit_tests_rbtree.py](unit_tests_rbtree.py) for sample usage.\n\n\n# References\n\n* [CLRS] Introduction to Algorithms 3rd Ed. Cormen, Thomas H. and Leiserson, Charles E. and Rivest, Ronald L. and Stein, Clifford, The MIT Press, 2001\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshoyamanishi%2Fredblacktree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshoyamanishi%2Fredblacktree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshoyamanishi%2Fredblacktree/lists"}