{"id":21235982,"url":"https://github.com/lddl/ch","last_synced_at":"2025-07-10T17:31:54.985Z","repository":{"id":52672747,"uuid":"188397946","full_name":"LdDl/ch","owner":"LdDl","description":"Contraction Hierarchies (with bidirectional version of Dijkstra's algorithm) technique for computing shortest path in graph.","archived":false,"fork":false,"pushed_at":"2023-12-07T00:06:00.000Z","size":109703,"stargazers_count":52,"open_issues_count":6,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-05T15:51:13.092Z","etag":null,"topics":["breadth-first-search","contraction-hierarchies","dijkstra","dijkstra-algorithm","graph","hacktoberfest","hacktoberfest-accepted","hactoberfest2022","isochrone-map","isochrones","osm","pathfinding","shortest-path-algorithm","shortest-paths","turn-restrictions"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LdDl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null}},"created_at":"2019-05-24T09:55:33.000Z","updated_at":"2025-03-15T12:54:16.000Z","dependencies_parsed_at":"2023-02-01T06:01:06.480Z","dependency_job_id":"5bc52d36-bf20-4b07-b0fe-facae423d7ec","html_url":"https://github.com/LdDl/ch","commit_stats":{"total_commits":307,"total_committers":5,"mean_commits":61.4,"dds":"0.12377850162866455","last_synced_commit":"6e44c52d9325bba6f264eb5bd7091cfc1535679e"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/LdDl/ch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Fch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Fch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Fch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Fch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LdDl","download_url":"https://codeload.github.com/LdDl/ch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LdDl%2Fch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264619111,"owners_count":23638407,"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":["breadth-first-search","contraction-hierarchies","dijkstra","dijkstra-algorithm","graph","hacktoberfest","hacktoberfest-accepted","hactoberfest2022","isochrone-map","isochrones","osm","pathfinding","shortest-path-algorithm","shortest-paths","turn-restrictions"],"created_at":"2024-11-21T00:05:28.928Z","updated_at":"2025-07-10T17:31:49.975Z","avatar_url":"https://github.com/LdDl.png","language":"Go","readme":"[![GoDoc](https://godoc.org/github.com/LdDl/ch?status.svg)](https://godoc.org/github.com/LdDl/ch)\n[![Build Status](https://travis-ci.com/LdDl/ch.svg?branch=master)](https://travis-ci.com/LdDl/ch)\n[![Sourcegraph](https://sourcegraph.com/github.com/LdDl/ch/-/badge.svg)](https://sourcegraph.com/github.com/LdDl/ch?badge)\n[![Go Report Card](https://goreportcard.com/badge/github.com/LdDl/ch)](https://goreportcard.com/report/github.com/LdDl/ch)\n[![GitHub tag](https://img.shields.io/github/tag/LdDl/ch.svg)](https://github.com/LdDl/ch/releases)\n\n# ch - Contraction Hierarchies\n## Contraction Hierarchies - technique for speed up of computing shortest path in graph.\n\nThis library provides [Contraction Hierarchies](https://en.wikipedia.org/wiki/Contraction_hierarchies) preprocessing graph technique for [Dijkstra's algorithm](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm). Classic implementation of Dijkstra's algorithm, maneuver restrictions extension and [isochrones](https://en.wikipedia.org/wiki/Isochrone_map) estimation are included also.\n\n## Table of Contents\n\n- [About](#about)\n- [Installation](#installation)\n    - [Go get](#go-get)\n    - [Go mod](#go-mod)\n- [Usage](#usage)\n- [Benchmark](#benchmark)\n- [Support](#support)\n- [ToDo](#todo)\n- [Thanks](#thanks)\n- [Theory](#theory)\n- [Dependencies](#dependencies)\n- [License](#license)\n\n## About\nThis package provides implemented next techniques and algorithms:\n* Dijkstra's algorithm\n* Contraction hierarchies\n* Bidirectional extension of Dijkstra's algorithm with contracted nodes\n\n## Installation\n\n### Go get\n```go\ngo get github.com/LdDl/ch\n```\n\n\n### Go mod \nIn your project folder execute next command (assuming you have GO111MODULE=on):\n```go\ngo mod init mod\n```\nThen import library into your code:\n```go\npackage main\n\nimport \"github.com/LdDl/ch\"\n\nfunc main() {\n\tx := ch.Graph{}\n\t_ = x\n}\n```\nand build\n```go\ngo build\n```\nYou will see next output:\n```shell\ngo: finding github.com/LdDl/ch v1.4.6\ngo: downloading github.com/LdDl/ch v1.4.6\n```\nAnd then you are good to go \n\n## Usage\n\n* Shortest path\n\n    Please see this [test file](bidirectional_ch_test.go#L17)\n\n    I hope it's pretty clear, but here is little explanation:\n    ```go\n    g := Graph{} // Prepare variable for storing graph\n    graphFromCSV(\u0026g, \"data/pgrouting_osm.csv\") // Import CSV-file file into programm\n    g.PrepareContractionHierarchies() // Compute contraction hierarchies\n    u := 144031 // Define source vertex\n    v := 452090 // Define target vertex\n    ans, path := g.ShortestPath(u, v) // Get shortest path and it's cost between source and target vertex\n    ```\n\n* Isochrones\n\n    Please see this [test file](isochrones_test.go#L7)\n    ```go\n    g := Graph{} // Prepare variable for storing graph\n    // ...\n    // Fill graph with data (vertices and edges)\n    // ...\n    isochrones, err := graph.Isochrones(sourceVertex, maxCost) // Evaluate isochrones via bread-first search\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n    }\n    ```\n    \n### If you want to import OSM (Open Street Map) file then follow instructions for [osm2ch](https://github.com/LdDl/osm2ch#osm2ch)\n\n## Benchmark\n\nYou can check benchmarks [here](https://github.com/LdDl/ch/blob/master/BENCHMARK.md)\n\n## Support\nIf you have troubles or questions please [open an issue](https://github.com/LdDl/ch/issues/new).\n\n## ToDo\n\nPlease see [ROADMAP.md](ROADMAP.md)\n\n## Theory\n[Dijkstra's algorithm](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm)\n\n[Bidirectional search](https://en.wikipedia.org/wiki/Bidirectional_search)\n\n[Bidirectional Dijkstra's algorithm's stop condition](http://www.cs.princeton.edu/courses/archive/spr06/cos423/Handouts/EPP%20shortest%20path%20algorithms.pdf)\n\n[Contraction hierarchies](https://en.wikipedia.org/wiki/Contraction_hierarchies)\n\n[Video Lectures](https://ad-wiki.informatik.uni-freiburg.de/teaching/EfficientRoutePlanningSS2012)\n\n\n## Thanks\nThanks to [this visual explanation](https://jlazarsfeld.github.io/ch.150.project/contents/)\nThanks to [this](https://github.com/navjindervirdee/Advanced-Shortest-Paths-Algorithms) Java implementation of mentioned algorithms\n\n## Dependencies\nThanks to [paulmach](https://github.com/paulmach) for his [OSM-parser](https://github.com/paulmach/osm) written in Go.\n\nPaulmach's license is [here](https://github.com/paulmach/osm/blob/master/LICENSE.md) (it's MIT)\n\n## License\nYou can check it [here](https://github.com/LdDl/ch/blob/master/LICENSE)\n\n[osm2ch]: (https://github.com/LdDl/osm2ch#osm2ch)\n[open an issue]: (https://github.com/LdDl/ch/issues/new)\n[BENCHMARK.md]: (https://github.com/LdDl/ch/blob/master/BENCHMARK.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flddl%2Fch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flddl%2Fch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flddl%2Fch/lists"}