{"id":32187574,"url":"https://github.com/biserkov/twotree-longest-path","last_synced_at":"2025-10-22T00:10:12.613Z","repository":{"id":62435029,"uuid":"75536037","full_name":"Biserkov/twotree-longest-path","owner":"Biserkov","description":"The code from my master thesis. 100.0% Clojure.","archived":false,"fork":false,"pushed_at":"2018-09-19T13:46:14.000Z","size":73,"stargazers_count":2,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T00:06:41.503Z","etag":null,"topics":["2-tree","algorithm","clojure","complexity","graph","iterative","linear","longest-path","memoization","property-based-testing","recursive","transients"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Biserkov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-04T12:29:18.000Z","updated_at":"2019-03-14T11:42:00.000Z","dependencies_parsed_at":"2022-11-01T21:02:42.947Z","dependency_job_id":null,"html_url":"https://github.com/Biserkov/twotree-longest-path","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Biserkov/twotree-longest-path","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biserkov%2Ftwotree-longest-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biserkov%2Ftwotree-longest-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biserkov%2Ftwotree-longest-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biserkov%2Ftwotree-longest-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Biserkov","download_url":"https://codeload.github.com/Biserkov/twotree-longest-path/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Biserkov%2Ftwotree-longest-path/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280354910,"owners_count":26316566,"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-10-21T02:00:06.614Z","response_time":58,"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":["2-tree","algorithm","clojure","complexity","graph","iterative","linear","longest-path","memoization","property-based-testing","recursive","transients"],"created_at":"2025-10-22T00:06:28.618Z","updated_at":"2025-10-22T00:10:12.609Z","avatar_url":"https://github.com/Biserkov.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# O(n) algorithm for computing longest paths in 2-trees\r\n\r\n[![Clojars Project](https://clojars.org/twotree.longest-path/latest-version.svg)](https://clojars.org/twotree.longest-path)\r\n\r\n[![cljdoc badge](https://cljdoc.xyz/badge/twotree.longest-path/twotree.longest-path)](https://cljdoc.xyz/d/twotree.longest-path/twotree.longest-path/CURRENT)\r\n\r\n## Overview\r\n\r\nIn 2013 Markov, Vassilev and Manev published a novel linear time [algorithm](https://sites.google.com/site/minkommarkov/longest-2-tree--draft.pdf?attredirects=0\u0026d=1) for computing longest paths in 2-trees.\r\n\r\nThis repository contains 3 implementations of said algorithm in Clojure:\r\n\r\nThe [first](https://github.com/Biserkov/twotree-longest-path/blob/master/test/longest_path/direct.clj) one is a direct implementation of the mathematical operations described in the paper. Due to the need to construct subgraphs to implement splitting, the time complexity is ```O(n√n)```.\r\n\r\nThe [second](https://github.com/Biserkov/twotree-longest-path/blob/master/test/longest_path/preprocessed.clj) one was suggested by Minko Markov and preprocesses the 2-tree, thus avoiding the need to construct subgraphs. The time complexity is ```O(n)```. Due to its recursive nature, this implementation will fail with a Stack Overflow Error if used on deep 2-trees with millions of vertices.\r\n\r\nThe [third](https://github.com/Biserkov/twotree-longest-path/blob/master/src/longest_path/iterative.clj) implementation is an iterative one. It uses the EdgeLabels map as a sort of explicit call stack. The time complexity is ```O(n)```.\r\n\r\nOnly the third one should be used for any practical purposes.\r\n\r\n## Data representation\r\n\r\nThe vertices of the graph are represented as positive integers.\r\n\r\nOn an abstract lever, the graph is represented as an adjacency list.\r\n\r\nOn a concrete level, it's a int-map in which a vertex acts as key and the corresponding values is an int-set of the its neighbours.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiserkov%2Ftwotree-longest-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiserkov%2Ftwotree-longest-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiserkov%2Ftwotree-longest-path/lists"}