{"id":15032927,"url":"https://github.com/ruby/tsort","last_synced_at":"2025-03-04T03:15:32.962Z","repository":{"id":42021828,"uuid":"266091939","full_name":"ruby/tsort","owner":"ruby","description":"Topological sorting using Tarjan's algorithm","archived":false,"fork":false,"pushed_at":"2024-09-10T06:13:08.000Z","size":54,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-02-25T02:14:20.896Z","etag":null,"topics":["ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/ruby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2020-05-22T11:17:11.000Z","updated_at":"2024-09-10T06:13:11.000Z","dependencies_parsed_at":"2023-11-07T05:11:03.125Z","dependency_job_id":"51e7bd47-4e43-488e-85c9-1731f93ae7d9","html_url":"https://github.com/ruby/tsort","commit_stats":{"total_commits":36,"total_committers":9,"mean_commits":4.0,"dds":0.5833333333333333,"last_synced_commit":"dd71002c65e4b0fa94c4ca38703b11efb9c367a0"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Ftsort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Ftsort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Ftsort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Ftsort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruby","download_url":"https://codeload.github.com/ruby/tsort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241773236,"owners_count":20018065,"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":["ruby"],"created_at":"2024-09-24T20:19:45.267Z","updated_at":"2025-03-04T03:15:32.944Z","avatar_url":"https://github.com/ruby.png","language":"Ruby","readme":"# TSort\n\nTSort implements topological sorting using Tarjan's algorithm for\nstrongly connected components.\n\nTSort is designed to be able to be used with any object which can be\ninterpreted as a directed graph.\n\nTSort requires two methods to interpret an object as a graph,\ntsort_each_node and tsort_each_child.\n\n* tsort_each_node is used to iterate for all nodes over a graph.\n* tsort_each_child is used to iterate for child nodes of a given node.\n\nThe equality of nodes are defined by eql? and hash since\nTSort uses Hash internally.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'tsort'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install tsort\n\n## Usage\n\nThe following example demonstrates how to mix the TSort module into an\nexisting class (in this case, Hash). Here, we're treating each key in\nthe hash as a node in the graph, and so we simply alias the required\n#tsort_each_node method to Hash's #each_key method. For each key in the\nhash, the associated value is an array of the node's child nodes. This\nchoice in turn leads to our implementation of the required #tsort_each_child\nmethod, which fetches the array of child nodes and then iterates over that\narray using the user-supplied block.\n\n```ruby\nrequire 'tsort'\n\nclass Hash\n  include TSort\n  alias tsort_each_node each_key\n  def tsort_each_child(node, \u0026block)\n    fetch(node).each(\u0026block)\n  end\nend\n\n{1=\u003e[2, 3], 2=\u003e[3], 3=\u003e[], 4=\u003e[]}.tsort\n#=\u003e [3, 2, 1, 4]\n\n{1=\u003e[2], 2=\u003e[3, 4], 3=\u003e[2], 4=\u003e[]}.strongly_connected_components\n#=\u003e [[4], [2, 3], [1]]\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/ruby/tsort.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby%2Ftsort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruby%2Ftsort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby%2Ftsort/lists"}