{"id":13910794,"url":"https://github.com/brettkromkamp/typed-tree","last_synced_at":"2025-04-14T22:44:29.619Z","repository":{"id":44164450,"uuid":"184400880","full_name":"brettkromkamp/typed-tree","owner":"brettkromkamp","description":"TypedTree provides a tree data structure that allows adding type information to both nodes and edges; useful for visualisation purposes","archived":false,"fork":false,"pushed_at":"2024-09-14T09:25:40.000Z","size":397,"stargazers_count":17,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T13:17:19.085Z","etag":null,"topics":["data-structures","hierarchical-data","hierarchical-models","python-3","tree-structure","visualization"],"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/brettkromkamp.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":"2019-05-01T10:29:44.000Z","updated_at":"2024-09-14T09:24:59.000Z","dependencies_parsed_at":"2024-11-01T07:03:52.542Z","dependency_job_id":"5ab12154-e382-42d2-84d1-6022297a68c7","html_url":"https://github.com/brettkromkamp/typed-tree","commit_stats":{"total_commits":60,"total_committers":3,"mean_commits":20.0,"dds":0.4666666666666667,"last_synced_commit":"9de6e4d03b169cfa157b9af72fe387fa1d0805b1"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettkromkamp%2Ftyped-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettkromkamp%2Ftyped-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettkromkamp%2Ftyped-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettkromkamp%2Ftyped-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brettkromkamp","download_url":"https://codeload.github.com/brettkromkamp/typed-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975291,"owners_count":21192198,"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":["data-structures","hierarchical-data","hierarchical-models","python-3","tree-structure","visualization"],"created_at":"2024-08-07T00:01:45.737Z","updated_at":"2025-04-14T22:44:29.601Z","avatar_url":"https://github.com/brettkromkamp.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# TypedTree by Brett Kromkamp\n\n[Contextualise](https://contextualise.dev/), a knowledge management application that I am currently developing, allows the user to visualise their topics of interest (that is, *nodes*) and the relationships between those topics (that is, *references to other nodes*) using a network graph visualisation. To that effect, TypedTree makes it straightforward to not only enable the visualisation of the actual (network) graph itself but also to enhance the visualisation with information related to the type of each node and the references to other nodes, respectively.\n\nTypedTree is based on an earlier implementation of mine: [Python tree implementation](https://github.com/caesar0301/treelib).\n\n## Installation\n\nTypedTree officially supports Python 3.7–3.10. To install TypedTree, simply:\n\n    $ pip install --upgrade typed-tree\n\n## Install the Development Version\n\nIf you have [Git](https://git-scm.com/) installed on your system, it is possible to install the development version of TypedTree.\n\nBefore installing the development version, you may need to uninstall the standard version of TypedTree using ``pip``:\n\n    $ pip uninstall typed-tree\n\nThen do:\n\n    $ git clone https://github.com/brettkromkamp/typed-tree\n    $ cd typed-tree\n    $ pip install -e .\n\nThe ``pip install -e .`` command allows you to follow the development branch as it changes by creating links in the right places and installing the command line scripts to the appropriate locations.\n\nThen, if you want to update TypedTree at any time, in the same directory do:\n\n    $ git pull\n\n## Example\n\n```python\nfrom typedtree import TraversalMode\nfrom typedtree import Tree\n\ntree = Tree()\n\n# A node without a parent pointer is by definition the root node\ntree.add_node('Elon Musk', node_type='person')\n\ntree.add_node('Lyndon Rive', parent_pointer='Elon Musk', node_type='person', edge_type='family')\ntree.add_node('SpaceX', parent_pointer='Elon Musk', node_type='company', edge_type='founder')\ntree.add_node('Tesla', parent_pointer='Elon Musk', node_type='company', edge_type='founder')\ntree.add_node('Solar City', parent_pointer='Lyndon Rive', node_type='company', edge_type='co-founder')\ntree.add_node('Solar Energy Services', parent_pointer='Solar City', node_type='product', edge_type='service')\ntree.add_node('Falcon 9', parent_pointer='SpaceX', node_type='rocket', edge_type='technology')\ntree.add_node('Falcon Heavy', parent_pointer='SpaceX', node_type='rocket', edge_type='technology')\ntree.add_node('Dragon', parent_pointer='SpaceX', node_type='space-ship', edge_type='technology')\ntree.add_node('Model S', parent_pointer='Tesla', node_type='car', edge_type='product')\ntree.add_node('Model X', parent_pointer='Tesla', node_type='car', edge_type='product')\ntree.add_node('Model Y', parent_pointer='Tesla', node_type='car', edge_type='product')\ntree.add_node('Roadster', parent_pointer='Tesla', node_type='car', edge_type='product')\n\nprint('\\n***** TREE STRUCTURE *****')\ntree.display('Elon Musk')\n\nprint('\\n***** DEPTH-FIRST ITERATION *****')\nfor node in tree.traverse('Elon Musk'):\n    print(f\"{node.identifier} [{node.type or '*Undefined*'}]\")\n\nprint('\\n***** BREADTH-FIRST ITERATION *****')\nfor node in tree.traverse('Elon Musk', mode=TraversalMode.BREADTH):\n    print(f\"{node.identifier} [{node.type or '*Undefined*'}]\")\n```\n\n**Output**\n\n```\n***** TREE STRUCTURE *****\nElon Musk [person] - (*Undefined*)\n        Lyndon Rive [person] - (family)\n            Solar City [company] - (co-founder)\n                Solar Energy Services [product] - (service)\n        SpaceX [company] - (founder)\n            Falcon 9 [rocket] - (technology)\n            Falcon Heavy [rocket] - (technology)\n            Dragon [space-ship] - (technology)\n        Tesla [company] - (founder)\n            Model S [car] - (product)\n            Model X [car] - (product)\n            Model Y [car] - (product)\n            Roadster [car] - (product)\n\n***** DEPTH-FIRST ITERATION *****\nElon Musk [person]\nLyndon Rive [person]\nSolar City [company]\nSolar Energy Services [product]\nSpaceX [company]\nFalcon 9 [rocket]\nFalcon Heavy [rocket]\nDragon [space-ship]\nTesla [company]\nModel S [car]\nModel X [car]\nModel Y [car]\nRoadster [car]\n\n***** BREADTH-FIRST ITERATION *****\nElon Musk [person]\nLyndon Rive [person]\nSpaceX [company]\nTesla [company]\nSolar City [company]\nFalcon 9 [rocket]\nFalcon Heavy [rocket]\nDragon [space-ship]\nModel S [car]\nModel X [car]\nModel Y [car]\nRoadster [car]\nSolar Energy Services [product]\n```\n\n## How to Contribute\n\n1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.\n2. Fork [the repository](https://github.com/brettkromkamp/typed-tree) on GitHub to start making your changes to the **master** branch (or branch off of it).\n3. Write a test which shows that the bug was fixed or that the feature works as expected.\n4. Send a pull request and bug the maintainer until it gets merged and published.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettkromkamp%2Ftyped-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrettkromkamp%2Ftyped-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettkromkamp%2Ftyped-tree/lists"}