{"id":18700902,"url":"https://github.com/rabestro/graph-pathfinding-algorithms","last_synced_at":"2026-03-05T06:31:27.562Z","repository":{"id":44149442,"uuid":"441857433","full_name":"rabestro/graph-pathfinding-algorithms","owner":"rabestro","description":"Implementation and tests for graph pathfinding algorithms.","archived":false,"fork":false,"pushed_at":"2024-07-09T14:14:34.000Z","size":624,"stargazers_count":5,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T08:38:32.325Z","etag":null,"topics":["algorithm","breadth-1st-search","breadth-first-search","dijkstra-algorithm","dijkstras-algorithm","graph","graph-algorithms","java","spock-framework","spring-shell"],"latest_commit_sha":null,"homepage":"https://algorithms.jc.id.lv/","language":"Java","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/rabestro.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-26T09:51:23.000Z","updated_at":"2023-07-15T08:37:34.000Z","dependencies_parsed_at":"2024-07-09T17:55:36.962Z","dependency_job_id":"9dc98db2-4c22-4690-a479-d9900e01cbbd","html_url":"https://github.com/rabestro/graph-pathfinding-algorithms","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rabestro/graph-pathfinding-algorithms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabestro%2Fgraph-pathfinding-algorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabestro%2Fgraph-pathfinding-algorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabestro%2Fgraph-pathfinding-algorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabestro%2Fgraph-pathfinding-algorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rabestro","download_url":"https://codeload.github.com/rabestro/graph-pathfinding-algorithms/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabestro%2Fgraph-pathfinding-algorithms/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30112226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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","breadth-1st-search","breadth-first-search","dijkstra-algorithm","dijkstras-algorithm","graph","graph-algorithms","java","spock-framework","spring-shell"],"created_at":"2024-11-07T11:39:44.269Z","updated_at":"2026-03-05T06:31:27.531Z","avatar_url":"https://github.com/rabestro.png","language":"Java","readme":"[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rabestro_algorithms\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=rabestro_algorithms)\n\n# Graph search algorithms\n\nThe project implements an interface for the weighted graph, as well as two algorithms for finding a path in the graph.\n\nThere are implementations and tests for two algorithms:\n\n- [Breadth-first search](https://en.wikipedia.org/wiki/Breadth-first_search)\n- [Dijkstra's Algorithm](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm)\n\nThe implementation is written in Java 17. [API documentation](https://algorithms.jc.id.lv/docs/api/) is available. You\ncan also see the [specifications](https://algorithms.jc.id.lv/docs/spock-reports/) generated with the spock-reports.\n\n## Demo. Graph Shell\n\nTo demonstrate the work of search algorithms, I made a small console program '[Graph Shell](graph-shell/README.md)'. The program\nallows you to select [one of three build-in graph samples](#Graph-Samples) and search for a path using two algorithms. The source\ncode of the program is located in `graph-shell` module.\n\n[![asciicast](https://asciinema.org/a/468058.svg)](https://asciinema.org/a/468058)\n\n### Usage in other projects\n\nThese algorithms used in the [Hypermetro](https://rabestro.github.io/hypermetro/) project, where they are\nutilized to find the optimal route in the metro schema.\n\n\n## How to use the algorithms in your program\n\nThe first step is to create a graph structure. The Graph interface is generic, so you can use any Java type for vertex\nand any [Number](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Number.html) type for distance.\n\n### Example\n\nIn the following Java code we create a graph structure with eight nodes. We\nuse [Character](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Character.html) class for vertex\nidentification and [Integer](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Integer.html) for the\ndistance. You can see the graphic representation of the scheme [here](docs/assets/complex.gif).\n\n```java\nvar graph = Graph.of(Map.of(\n            'A', Map.of('B', 5, 'H', 2),\n            'B', Map.of('A', 5, 'C', 7),\n            'C', Map.of('B', 7, 'D', 3, 'G', 4),\n            'D', Map.of('C', 20, 'E', 4),\n            'E', Map.of('F', 5),\n            'F', Map.of('G', 6),\n            'G', Map.of('C', 4),\n            'H', Map.of('G', 3)\n    ));\n```\n\nThe second step is creating a search algorithm class. You can choose one of the two algorithms.\n\n### Example\n\n```java\nvar fastest = new DijkstrasAlgorithm\u003cCharacter\u003e();\nvar shortest = new BreadthFirstSearch\u003cCharacter\u003e();\n```\n\nNow we can search for the route.\n\n### Example\n\n```java\nvar source = 'D';\nvar target = 'C';\n\nvar routeOne = shortest.findPath(graph, source, target);\nvar routeTwo = fastest.findPath(graph, source, target);\n```\n\nAs result, you get a list with the path.\n\n```java\nrouteOne==['D','C']\n        routeTwo==['D','E','F','G','C']\n```\n\n## Unit Tests\n\nTests are written in Groove language. For unit testing, the [Spock Framework](https://spockframework.org/) was used. To test the operation of the algorithms, the following sample graphs were created.\n\n## Graph Samples\n\n### Small Graph Sample\n\n```mermaid\nflowchart LR\n    A((A))\n    B((B))\n    C((C))\n    A --\u003e|7| B\n    A --\u003e|2| C\n    B --\u003e|3| A\n    B --\u003e|5| C\n    C --\u003e|1| A\n    C --\u003e|3| B\n```\n\n![Small Graph](docs/assets/small.gif)\n\n\n### Medium Graph Sample\n\n```mermaid\nflowchart LR\n    A --\u003e |5 | B\n    B --\u003e |5 | A\n    B --\u003e |10| C\n    C --\u003e |5 | D\n    C --\u003e |20| B\n    D --\u003e |5 | E\n    E --\u003e |5 | B\n```\n\n![Medium Graph](docs/assets/medium.gif)\n\n### Complex Graph Sample\n\n```mermaid\nflowchart LR\n    A --\u003e |5 | B\n    A --\u003e |2 | H\n    B --\u003e |5 | A\n    B --\u003e |7 | C\n    C --\u003e |7 | B\n    C --\u003e |3 | D\n    C --\u003e |4 | G\n    D --\u003e |20| C\n    D --\u003e |4 | E\n    E --\u003e |5 | F\n    G --\u003e |4 | C\n    H --\u003e |3 | G\n```\n\n![Complex Graph](docs/assets/complex.gif)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frabestro%2Fgraph-pathfinding-algorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frabestro%2Fgraph-pathfinding-algorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frabestro%2Fgraph-pathfinding-algorithms/lists"}