{"id":21169769,"url":"https://github.com/andreasgrv/itree","last_synced_at":"2025-03-14T17:23:52.989Z","repository":{"id":72076921,"uuid":"60696960","full_name":"andreasgrv/itree","owner":"andreasgrv","description":"an indexable tree data structure","archived":false,"fork":false,"pushed_at":"2016-06-10T11:54:53.000Z","size":153,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T10:50:54.099Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreasgrv.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":"2016-06-08T12:42:51.000Z","updated_at":"2016-06-08T12:45:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"6dcca44c-d7aa-4eb0-9f5a-0e27012b59dd","html_url":"https://github.com/andreasgrv/itree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasgrv%2Fitree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasgrv%2Fitree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasgrv%2Fitree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreasgrv%2Fitree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreasgrv","download_url":"https://codeload.github.com/andreasgrv/itree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243616382,"owners_count":20319890,"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":[],"created_at":"2024-11-20T15:53:37.900Z","updated_at":"2025-03-14T17:23:52.983Z","avatar_url":"https://github.com/andreasgrv.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# i-tree\n\n[![Test Status](https://api.travis-ci.org/andreasgrv/itree.svg?branch=master)](https://travis-ci.org/andreasgrv/itree)\n\ndisclaimer: you can't listen to songs on an i-tree\n\n## what is it then?\n\n### something like an indexable tree\n\nAt some point I wanted a treelike structure with list-like access using indices. I'm not sure this\nis necessarily a good idea, but I tried to do it anyways.\nI noticed I could probably get away with using 2 indices, a vertical index (depth) and a horizontal\nindex (width). Those two numbers should uniquely identify a node in the tree if we use:\n\n\t* depth = distance from root to \"lowest\" leaf node\n\t* width = number of nodes away from last node on the left on that level\n\nSo here it is.\n\n![A 3 level itree](doc/itree.png?raw=true \"A 3 level itree\")\n\n## how is it implemented?\n\nWell, it's pretty obvious that you might as well use an array of arrays of dynamic size to store the nodes.\nThat way the nodes are indexable using 2 indices. Nodes of course, have to contain pointers to a parent\nnode and their child nodes in order to represent the treeish information.\n\nBut we can probably do better than that, since we could encode the tree information as functions of the array\nindices. We can use each row in the outer array to represent a level of the tree\nstarting from the root. That way we know that if we are on level i, our parent is necessarily on level i-1 and our\nchildren on i+1. That way we can get away with only storing one index for the parent and the children, namely\nthe width (\\# nodes away from last node on the left).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreasgrv%2Fitree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreasgrv%2Fitree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreasgrv%2Fitree/lists"}