{"id":16856394,"url":"https://github.com/vallentin/traversal","last_synced_at":"2025-04-11T07:39:40.784Z","repository":{"id":57670572,"uuid":"246391229","full_name":"vallentin/traversal","owner":"vallentin","description":"Generic and lazy tree traversal algorithms","archived":false,"fork":false,"pushed_at":"2020-07-12T20:23:44.000Z","size":30,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T05:11:33.766Z","etag":null,"topics":["rust","rust-crate","rust-library","traversal","tree-traversal"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/vallentin.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}},"created_at":"2020-03-10T19:37:33.000Z","updated_at":"2025-03-20T17:10:05.000Z","dependencies_parsed_at":"2022-09-26T20:41:09.189Z","dependency_job_id":null,"html_url":"https://github.com/vallentin/traversal","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Ftraversal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Ftraversal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Ftraversal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Ftraversal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vallentin","download_url":"https://codeload.github.com/vallentin/traversal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248359158,"owners_count":21090484,"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":["rust","rust-crate","rust-library","traversal","tree-traversal"],"created_at":"2024-10-13T14:04:06.942Z","updated_at":"2025-04-11T07:39:40.753Z","avatar_url":"https://github.com/vallentin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# traversal\n\n[![Build Status](https://github.com/vallentin/traversal/workflows/Rust/badge.svg)](https://github.com/vallentin/traversal/actions?query=workflow%3ARust)\n[![Build Status](https://travis-ci.org/vallentin/traversal.svg?branch=master)](https://travis-ci.org/vallentin/traversal)\n[![Latest Version](https://img.shields.io/crates/v/traversal.svg)](https://crates.io/crates/traversal)\n[![Docs](https://docs.rs/traversal/badge.svg)](https://docs.rs/traversal)\n[![License](https://img.shields.io/github/license/vallentin/traversal.svg)](https://github.com/vallentin/traversal)\n\nTraversal implements generic and lazy tree traversal algorithms.\n\nIncludes:\n- [Breadth-First Traversal] ([`Bft`])\n- [Depth-First Traversal] in Pre-Order ([`DftPre`])\n- [Depth-First Traversal] in Post-Order ([`DftPost`])\n- Reverse [Depth-First Traversal] in Pre-Order ([`DftPreRev`])\n- Reverse [Depth-First Traversal] in Post-Order ([`DftPostRev`])\n\u003c!----\u003e\n- All Paths ([`DftPaths`])\n- Longest Paths ([`DftLongestPaths`])\n- All Cycles (Paths) ([`DftCycles`])\n\n[Breadth-First Traversal]: https://en.wikipedia.org/wiki/Tree_traversal\n[Depth-First Traversal]: https://en.wikipedia.org/wiki/Tree_traversal\n\n### Generic\n\nTraversal uses [generics] (or [type parameters]) to be\nflexible to use, and easy to implement and fit into existing\narchitecture.\n\n[generics]: https://doc.rust-lang.org/rust-by-example/generics.html\n[type parameters]: https://doc.rust-lang.org/reference/types/parameters.html\n\n### Laziness\n\nLaziness or [lazy evaluation] refers to evaluation being delayed\nuntil needed.\n\nTraversal delays processing `Node`s and fetching child `Node`s\nuntil [`Iterator::next`][`next`] is called.\nWhen [`next`] is called, then traversal only processes the\n`Node`s required for this iteration.\n\n[lazy evaluation]: https://en.wikipedia.org/wiki/Lazy_evaluation\n\n*From Rust's docs:*\n\n\u003e *Iterators (and iterator [adapters]) are lazy. This means that just\n\u003e creating an iterator doesn't do a whole lot. Nothing really happens\n\u003e until you call [`next`].*\n\u003e\n\u003e \u0026mdash; [`Iterator`] - [Laziness]\n\n[`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html\n[`next`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#tymethod.next\n\n[Laziness]: https://doc.rust-lang.org/std/iter/index.html#laziness\n[adapters]: https://doc.rust-lang.org/std/iter/index.html#adapters\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\ntraversal = \"0.1\"\n```\n\n## Releases\n\nRelease notes are available in the repo at [CHANGELOG.md].\n\n[CHANGELOG.md]: CHANGELOG.md\n\n## Algorithms\n\n```text\n     A\n    / \\\n   B   C\n  / \\ / \\\n D  E F  G\n```\n\nGiven the above tree, then the following are the orders,\nthat each individual iterator / traversal algorithm produces.\n\n| Algorithm | Order |\n|-----------|-------|\n| [`Bft`]        (Breadth-First Traversal)                     | A, B, C, D, E, F, G |\n| [`DftPre`]     (Depth-First Traversal in Pre-Order)          | A, B, D, E, C, F, G |\n| [`DftPost`]    (Depth-First Traversal in Post-Order)         | D, E, B, F, G, C, A |\n| [`DftPreRev`]  (Reverse Depth-First Traversal in Pre-Order)  | G, F, C, E, D, B, A |\n| [`DftPostRev`] (Reverse Depth-First Traversal in Post-Order) | A, C, G, F, B, E, D |\n\n*See each individual algorithm for code examples.*\n\n[`Bft`]: https://docs.rs/traversal/*/traversal/struct.Bft.html\n[`DftPre`]: https://docs.rs/traversal/*/traversal/struct.DftPre.html\n[`DftPost`]: https://docs.rs/traversal/*/traversal/struct.DftPost.html\n[`DftPreRev`]: https://docs.rs/traversal/*/traversal/struct.DftPreRev.html\n[`DftPostRev`]: https://docs.rs/traversal/*/traversal/struct.DftPostRev.html\n\n### All Paths and Longest Paths\n\n[`DftPaths`] and [`DftLongestPaths`] are utilities for\niterating all paths and the longest paths in a tree.\n\n*Given the same tree as the previous examples, then\n[`DftPaths`] and [`DftLongestPaths`] produce the\nfollowing paths.*\n\n[`DftPaths`]:\n- A, B\n- A, B, D\n- A, B, E\n- A, C\n- A, C, F\n- A, C, G\n\n[`DftLongestPaths`]:\n- A, B, D\n- A, B, E\n- A, C, F\n- A, C, G\n\n*See each individual algorithm for code examples.*\n\n[`DftPaths`]: https://docs.rs/traversal/*/traversal/struct.DftPaths.html\n[`DftLongestPaths`]: https://docs.rs/traversal/*/traversal/struct.DftLongestPaths.html\n\n## Cycles\n\n```text\n  A \u003c---+\n / \\    |\nB   D \u003e-+\n|   |   |\nC   E \u003e-+\n```\n\n[`DftCycles`]:\n- A -\u003e D (*implies D is connected with A*)\n- A -\u003e D -\u003e E\n\n*See each individual algorithm for code examples.*\n\n[`DftCycles`]: https://docs.rs/traversal/*/traversal/struct.DftCycles.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Ftraversal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvallentin%2Ftraversal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Ftraversal/lists"}