github.com/LdDl/ch@v1.7.8/README.md (about)

     1  [![GoDoc](https://godoc.org/github.com/LdDl/ch?status.svg)](https://godoc.org/github.com/LdDl/ch)
     2  [![Build Status](https://travis-ci.com/LdDl/ch.svg?branch=master)](https://travis-ci.com/LdDl/ch)
     3  [![Sourcegraph](https://sourcegraph.com/github.com/LdDl/ch/-/badge.svg)](https://sourcegraph.com/github.com/LdDl/ch?badge)
     4  [![Go Report Card](https://goreportcard.com/badge/github.com/LdDl/ch)](https://goreportcard.com/report/github.com/LdDl/ch)
     5  [![GitHub tag](https://img.shields.io/github/tag/LdDl/ch.svg)](https://github.com/LdDl/ch/releases)
     6  
     7  # ch - Contraction Hierarchies
     8  ## Contraction Hierarchies - technique for speed up of computing shortest path in graph.
     9  
    10  This 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.
    11  
    12  ## Table of Contents
    13  
    14  - [About](#about)
    15  - [Installation](#installation)
    16      - [Go get](#go-get)
    17      - [Go mod](#go-mod)
    18  - [Usage](#usage)
    19  - [Benchmark](#benchmark)
    20  - [Support](#support)
    21  - [ToDo](#todo)
    22  - [Thanks](#thanks)
    23  - [Theory](#theory)
    24  - [Dependencies](#dependencies)
    25  - [License](#license)
    26  
    27  ## About
    28  This package provides implemented next techniques and algorithms:
    29  * Dijkstra's algorithm
    30  * Contraction hierarchies
    31  * Bidirectional extension of Dijkstra's algorithm with contracted nodes
    32  
    33  ## Installation
    34  
    35  ### Go get
    36  ```go
    37  go get github.com/LdDl/ch
    38  ```
    39  
    40  
    41  ### Go mod 
    42  In your project folder execute next command (assuming you have GO111MODULE=on):
    43  ```go
    44  go mod init mod
    45  ```
    46  Then import library into your code:
    47  ```go
    48  package main
    49  
    50  import "github.com/LdDl/ch"
    51  
    52  func main() {
    53  	x := ch.Graph{}
    54  	_ = x
    55  }
    56  ```
    57  and build
    58  ```go
    59  go build
    60  ```
    61  You will see next output:
    62  ```shell
    63  go: finding github.com/LdDl/ch v1.4.6
    64  go: downloading github.com/LdDl/ch v1.4.6
    65  ```
    66  And then you are good to go 
    67  
    68  ## Usage
    69  
    70  * Shortest path
    71  
    72      Please see this [test file](bidirectional_ch_test.go#L17)
    73  
    74      I hope it's pretty clear, but here is little explanation:
    75      ```go
    76      g := Graph{} // Prepare variable for storing graph
    77      graphFromCSV(&g, "data/pgrouting_osm.csv") // Import CSV-file file into programm
    78      g.PrepareContractionHierarchies() // Compute contraction hierarchies
    79      u := 144031 // Define source vertex
    80      v := 452090 // Define target vertex
    81      ans, path := g.ShortestPath(u, v) // Get shortest path and it's cost between source and target vertex
    82      ```
    83  
    84  * Isochrones
    85  
    86      Please see this [test file](isochrones_test.go#L7)
    87      ```go
    88      g := Graph{} // Prepare variable for storing graph
    89      // ...
    90      // Fill graph with data (vertices and edges)
    91      // ...
    92      isochrones, err := graph.Isochrones(sourceVertex, maxCost) // Evaluate isochrones via bread-first search
    93  	if err != nil {
    94  		t.Error(err)
    95  		return
    96      }
    97      ```
    98      
    99  ### If you want to import OSM (Open Street Map) file then follow instructions for [osm2ch](https://github.com/LdDl/osm2ch#osm2ch)
   100  
   101  ## Benchmark
   102  
   103  You can check benchmarks [here](https://github.com/LdDl/ch/blob/master/BENCHMARK.md)
   104  
   105  ## Support
   106  If you have troubles or questions please [open an issue](https://github.com/LdDl/ch/issues/new).
   107  
   108  ## ToDo
   109  
   110  Please see [ROADMAP.md](ROADMAP.md)
   111  
   112  ## Theory
   113  [Dijkstra's algorithm](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm)
   114  
   115  [Bidirectional search](https://en.wikipedia.org/wiki/Bidirectional_search)
   116  
   117  [Bidirectional Dijkstra's algorithm's stop condition](http://www.cs.princeton.edu/courses/archive/spr06/cos423/Handouts/EPP%20shortest%20path%20algorithms.pdf)
   118  
   119  [Contraction hierarchies](https://en.wikipedia.org/wiki/Contraction_hierarchies)
   120  
   121  [Video Lectures](https://ad-wiki.informatik.uni-freiburg.de/teaching/EfficientRoutePlanningSS2012)
   122  
   123  
   124  ## Thanks
   125  Thanks to [this visual explanation](https://jlazarsfeld.github.io/ch.150.project/contents/)
   126  Thanks to [this](https://github.com/navjindervirdee/Advanced-Shortest-Paths-Algorithms) Java implementation of mentioned algorithms
   127  
   128  ## Dependencies
   129  Thanks to [paulmach](https://github.com/paulmach) for his [OSM-parser](https://github.com/paulmach/osm) written in Go.
   130  
   131  Paulmach's license is [here](https://github.com/paulmach/osm/blob/master/LICENSE.md) (it's MIT)
   132  
   133  ## License
   134  You can check it [here](https://github.com/LdDl/ch/blob/master/LICENSE)
   135  
   136  [osm2ch]: (https://github.com/LdDl/osm2ch#osm2ch)
   137  [open an issue]: (https://github.com/LdDl/ch/issues/new)
   138  [BENCHMARK.md]: (https://github.com/LdDl/ch/blob/master/BENCHMARK.md)