1*d86ed7fbStbbdev# Shortpath sample 2*d86ed7fbStbbdevThis directory contains an example that solves the single source shortest path problem. 3*d86ed7fbStbbdev 4*d86ed7fbStbbdevIt is parameterized by `N`, a number of nodes, and a start and end node in `[0..N)`. A graph is generated with `N` nodes and some random number of connections between those nodes. A parallel algorithm based on `A*` is used to find the shortest path. 5*d86ed7fbStbbdev 6*d86ed7fbStbbdevThis algorithm varies from serial `A*` in that it needs to add nodes back to the open set when the `g` estimate (shortest path from start to the node) is improved, even if the node has already been "visited". This is because nodes are added and removed from the open-set in parallel, resulting in some less optimal paths being explored. The open-set is implemented with the `concurrent_priority_queue`. 7*d86ed7fbStbbdev 8*d86ed7fbStbbdevNote that since we re-visit nodes, the `f` estimate (on which the priority queue is sorted) is not technically needed, so we could use this same parallel algorithm with just a `concurrent_queue`. However, keeping the `f` estimate and using `concurrent_priority_queue` results in much better performance. 9*d86ed7fbStbbdev 10*d86ed7fbStbbdevSilent mode prints run time only, regular mode prints the shortest path length, and verbose mode prints out the shortest path. 11*d86ed7fbStbbdev 12*d86ed7fbStbbdevThe generated graph follows a pattern in which the closer two pairs of node ids are together, the fewer hops there are in a typical path between those nodes. So, for example, the path between 5 and 7 likely has few hops whereas 14 to 78 has more and 0 to 9999 has even more, etc. 13*d86ed7fbStbbdev 14*d86ed7fbStbbdev## Building the example 15*d86ed7fbStbbdev``` 16*d86ed7fbStbbdevcmake <path_to_example> 17*d86ed7fbStbbdevcmake --build . 18*d86ed7fbStbbdev``` 19*d86ed7fbStbbdev 20*d86ed7fbStbbdev## Running the sample 21*d86ed7fbStbbdev### Predefined make targets 22*d86ed7fbStbbdev* `make run_shortpath` - executes the example with predefined parameters. 23*d86ed7fbStbbdev* `make perf_run_shortpath` - executes the example with suggested parameters to measure the oneTBB performance. 24*d86ed7fbStbbdev 25*d86ed7fbStbbdev### Application parameters 26*d86ed7fbStbbdevUsage: 27*d86ed7fbStbbdev``` 28*d86ed7fbStbbdevshortpath [#threads=value] [verbose] [silent] [N=value] [start=value] [end=value] [-h] [#threads] 29*d86ed7fbStbbdev``` 30*d86ed7fbStbbdev* `-h` - prints the help for command line options. 31*d86ed7fbStbbdev* `n-of-threads` - number of threads to use; a range of the form low[:high], where low and optional high are non-negative integers or `auto` for a platform-specific default number. 32*d86ed7fbStbbdev* `verbose` - prints diagnostic output to screen. 33*d86ed7fbStbbdev* `silent` - no output except elapsed time. 34*d86ed7fbStbbdev* `N` - number of nodes in graph. 35*d86ed7fbStbbdev* `start` - node to start path at. 36*d86ed7fbStbbdev* `end` - node to end path at. 37