{"id":43312977,"url":"https://github.com/jakesherman/dependency_algorithm","last_synced_at":"2026-02-01T21:38:42.461Z","repository":{"id":55126908,"uuid":"65858780","full_name":"jakesherman/dependency_algorithm","owner":"jakesherman","description":":arrow_forward: Python package for efficiently resolving dependencies","archived":false,"fork":false,"pushed_at":"2021-01-08T05:04:14.000Z","size":104,"stargazers_count":6,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-09T06:56:27.397Z","etag":null,"topics":["algorithm","dependencies","dependency","dependency-algorithms","dependency-graph","python","recursion"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/jakesherman.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}},"created_at":"2016-08-16T22:49:14.000Z","updated_at":"2025-07-06T03:00:33.000Z","dependencies_parsed_at":"2022-08-14T12:50:26.331Z","dependency_job_id":null,"html_url":"https://github.com/jakesherman/dependency_algorithm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jakesherman/dependency_algorithm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakesherman%2Fdependency_algorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakesherman%2Fdependency_algorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakesherman%2Fdependency_algorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakesherman%2Fdependency_algorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakesherman","download_url":"https://codeload.github.com/jakesherman/dependency_algorithm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakesherman%2Fdependency_algorithm/sbom","scorecard":{"id":502671,"data":{"date":"2025-08-11","repo":{"name":"github.com/jakesherman/dependency_algorithm","commit":"59dfa681571a8c0d3459956dcc933d4597797006"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/4 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T22:22:32.571Z","repository_id":55126908,"created_at":"2025-08-19T22:22:32.571Z","updated_at":"2025-08-19T22:22:32.571Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28991777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T20:57:35.821Z","status":"ssl_error","status_checked_at":"2026-02-01T20:57:29.580Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","dependencies","dependency","dependency-algorithms","dependency-graph","python","recursion"],"created_at":"2026-02-01T21:38:41.944Z","updated_at":"2026-02-01T21:38:42.447Z","avatar_url":"https://github.com/jakesherman.png","language":"Jupyter Notebook","readme":"# Dependency Algorithm\n\nHere is my take on an algorithm in Python 3.7 that resolves dependencies. The best way to illustrate how this works is with an example...\n\n## Example \n\nLet's say that we have the following dictionary where the keys are items, and the values are the dependencies of those items. Each dependency must itself be an item, and items with no dependencies have an empty list `[]` as they dependency:\n\n```python\nmy_items = {\n    'A': ['B', 'C', 'D'],  # -- A is dependent on B, C, D,\n    'B': [],  # -- B is dependent on nothing, etc.\n    'C': ['D'],\n    'D': ['B', 'E'],\n    'E': ['F'],\n    'F': [],\n    'Z': ['A', 'B', 'C', 'D']\n}\n```\n\nNote that we've only provided a partial dictionary of items to their dependencies...for example, notice how C is dependent on D, which is dependent on B (no dependencies) and E, which is dependent on F...therefore, C is dependent on D, B, E, and F. \n\nWe can use the `Dependencies` class to get the complete list of dependencies for an item, like so:\n\n```python\nfrom dependency_algorithm import Dependencies\n\n# Creating a Dependencies object\ndependencies = Dependencies(my_items)\ndependencies.complete_dependencies(\"C\")\n```\n\n```\n\u003e\u003e\u003e ['D', 'B', 'E', 'F']\n```\n\nMore importantly, we can return the items in an order such that the dependencies resolve:\n\n```python\ndependencies.resolve_dependencies()\n```\n\n```\n\u003e\u003e\u003e ['B', 'F', 'E', 'D', 'C', 'A', 'Z']\n```\n\nIn many cases, there are multiple correct ordering of our items such that each item's dependencies resolve. If we're interested in all possible correct orderings, the `Dependencies` class can permutate over all possible orderings, and identify the correct ones (albeit at a high computational cost), like so:\n\n```python\ndependencies.all_possible_resolution_orders(verbose=True)\n```\n\n```\n\u003e\u003e\u003e Number of permutations: 5040\n\u003e\u003e\u003e Number of correct orderings: 3\n\u003e\u003e\u003e Number of incorrect orderings: 5037\n\u003e\u003e\u003e [('B', 'F', 'E', 'D', 'C', 'A', 'Z'),\n\u003e\u003e\u003e  ('F', 'B', 'E', 'D', 'C', 'A', 'Z'),\n\u003e\u003e\u003e  ('F', 'E', 'B', 'D', 'C', 'A', 'Z')]\n```\n\nThat's pretty much it! The `Dependencies` class also performs two checks, one for any dependencies that are \"missing\" (i.e., they are not keys in the input dictionary of items and dependencies), and another for cirular dependencies (i.e., A is dependent on B which is dependent on A which is...and so on...).\n\n## Installation\n\nRequires Python 3.7 or greater.\n\n```\npip install dependency_algorithm\n```\n\n## Running the unit tests with `pytest`\n\n```\ngit clone https://github.com/jakesherman/dependency_algorithm.git\ncd dependency_algorithm\npip install -e .\npython -m pytest\n```\n\n## Future work\n\n* New version of `Dependencies._enhanced_list_dependencies` that uses iteration instead of recursion\n* Improved version of `Dependencies.all_possible_resolution_orders` that uses a more efficient algorithm than looping through permutations, ex. a recursive algorithm\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakesherman%2Fdependency_algorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakesherman%2Fdependency_algorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakesherman%2Fdependency_algorithm/lists"}