{"id":21011059,"url":"https://github.com/ruby-ist/dijkstra_trace","last_synced_at":"2025-08-02T04:32:51.734Z","repository":{"id":48790606,"uuid":"517027583","full_name":"ruby-ist/dijkstra_trace","owner":"ruby-ist","description":"A ruby gem for dijkstra Algorithm implementation","archived":false,"fork":false,"pushed_at":"2023-01-10T05:52:19.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-27T14:21:14.547Z","etag":null,"topics":["dijkstra-shortest-path","ruby","rubygems"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/dijkstra_trace","language":"Ruby","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/ruby-ist.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":"2022-07-23T10:34:10.000Z","updated_at":"2022-08-03T11:25:15.000Z","dependencies_parsed_at":"2023-02-08T17:31:37.846Z","dependency_job_id":null,"html_url":"https://github.com/ruby-ist/dijkstra_trace","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ruby-ist/dijkstra_trace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-ist%2Fdijkstra_trace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-ist%2Fdijkstra_trace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-ist%2Fdijkstra_trace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-ist%2Fdijkstra_trace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruby-ist","download_url":"https://codeload.github.com/ruby-ist/dijkstra_trace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby-ist%2Fdijkstra_trace/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268204324,"owners_count":24212689,"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-08-01T02:00:08.611Z","response_time":67,"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":["dijkstra-shortest-path","ruby","rubygems"],"created_at":"2024-11-19T09:25:26.090Z","updated_at":"2025-08-02T04:32:51.703Z","avatar_url":"https://github.com/ruby-ist.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dijkstra Trace \n\n[![Gem Version](https://badge.fury.io/rb/dijkstra_trace.svg)](https://badge.fury.io/rb/dijkstra_trace)\n\nA simple Dijkstra algorithm implementation to find the shortest path between any two points in the undirected graph. \n\n## Installation\n\nInstall the gem by adding the following line in your Gemfile and run `bundle install`\n```ruby\ngem 'dijkstra_trace'\n```\nor simply run `bundle add dijkstra_trace`\n## Usage\n\nCreate an object for `Dijkstra::Trace` class with the graph edges as its argument.\n```ruby\nrequire 'dijkstra_trace'\n\nedges = [\n    [0,1,55],\n    [1,2,100],\n    [0,3,75],\n    [3,4,60],\n    [1,4,75],\n    [3,6,50],\n    [4,7,50],\n    [6,7,65],\n    [2,5,95],\n    [5,8,65],\n    [7,8,40],\n    [8,9,40],\n    [9,10,40],\n    [9,11,50],\n    [10,12,75],\n    [11,13,110],\n    [12,13,50]\n]\n\n\ngraph = Dijkstra::Trace.new(edges)\npath = graph.path(2,13)\n\nputs \"The shortest distance between #{path.starting_point} and #{path.ending_point} is #{path.distance} units\"\nputs \"The shortest path: #{path.path}\"\n\n```\n### Output\n```\nThe shortest distance between 2 and 13 is 360 units\nThe shortest path: [2, 5, 8, 9, 11, 13]\n```\n\nThe Vertices is not only limited to numbers, it can be any type as long as it can be used as a key for an `Hash`\n```ruby\nedges = [\n    [\"City A\", \"City B\", 200],\n    [\"City B\", \"City C\", 60],\n    [\"City A\", \"City C\", 270],\n]\ngraph = Dijkstra::Trace.new(edges)\npath = graph.path(\"City A\", \"City C\")\npp path.path\n```\n### Output\n```\n[\"City A\", \"City B\", \"City C\"]\n```\nThe Graph matrix and the adjacent matrix can also be viewed by calling the methods `graph_matrix` and `adjacent_matrix` on the `Dijkstra::Trace` class object.\n\nGraph Matrix for the first output:\n```\nirb(main):001:0\u003e pp graph.graph_matrix\n\n[[0, 55, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n [55, 0, 100, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n [0, 100, 0, 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, 0],\n [75, 0, 0, 0, 60, 0, 50, 0, 0, 0, 0, 0, 0, 0],\n [0, 75, 0, 60, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0],\n [0, 0, 95, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0, 0],\n [0, 0, 0, 50, 0, 0, 0, 65, 0, 0, 0, 0, 0, 0],\n [0, 0, 0, 0, 50, 0, 65, 0, 40, 0, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 65, 0, 40, 0, 40, 0, 0, 0, 0],\n [0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 40, 50, 0, 0],\n [0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 75, 0],\n [0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 110],\n [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 0, 0, 50],\n [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 110, 50, 0]]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby-ist%2Fdijkstra_trace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruby-ist%2Fdijkstra_trace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby-ist%2Fdijkstra_trace/lists"}