Skip to content

Commit

Permalink
Update the documentation.
Browse files Browse the repository at this point in the history
Describe the example appliation and add screenshot of the resulting
road network created by the library.
  • Loading branch information
vahancho committed Dec 5, 2023
1 parent 4ac3342 commit 4f93782
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
creation of graphs of any types of nodes both directed and undirected with
the custom weight function.

[![Latest release](https://img.shields.io/github/v/release/vahancho/graphene?include_prereleases)](https://github.com/vahancho/graphene/releases)
[![Build and test (CMake)](https://github.com/vahancho/graphene/actions/workflows/cmake.yml/badge.svg)](https://github.com/vahancho/graphene/actions/workflows/cmake.yml)
[![Code coverage](https://codecov.io/gh/vahancho/graphene/graph/badge.svg?token=YLMFIEZBGG)](https://codecov.io/gh/vahancho/graphene)
[![Latest release](https://img.shields.io/github/v/release/vahancho/graphene?include_prereleases)]
(https://github.com/vahancho/graphene/releases)
[![Build and test (CMake)](https://github.com/vahancho/graphene/actions/workflows/cmake.yml/badge.svg)]
(https://github.com/vahancho/graphene/actions/workflows/cmake.yml)
[![Code coverage](https://codecov.io/gh/vahancho/graphene/graph/badge.svg?token=YLMFIEZBGG)]
(https://codecov.io/gh/vahancho/graphene)

## Prerequisites

Expand All @@ -27,6 +30,8 @@ not only the shortest path, but the path that corresponds to the minimal overall
## API and usage

```cpp
#include "graphene.h"

// Declare a graph with nodes as integer values
Graphene<int> graph;

Expand All @@ -41,6 +46,7 @@ graph.addEdge(1, 2);
Calculate the shortest path between two nodes

```cpp
#include "graphene.h"

// 1--2--5--8
// \ \/
Expand All @@ -63,11 +69,22 @@ graph.addEdge(6, 7);

path = graph.shortestPath(1, 6, weightFunction);
// path = {1, 2, 5, 6}

```

## Example (California road network)

The `roadmap` example demonstrates how to use `Graphene` library to create a road
map. As an input we used the [California Road Network]
(https://users.cs.utah.edu/~lifeifei/SpatialDataset.htm) which represented by two files:
`/examples/data/nodes_lon_lat.txt` with the nodes' geodetic coordinates and
`/examples/data/edges.txt` file with nodes indexes and distance between them.
Using this data we created an undirected graph and use `Graphene::shortestPaths()`
function to find all paths that connect a node with all others. The tool exports
the results as a [KML](https://en.wikipedia.org/wiki/Keyhole_Markup_Language) file
which can be loaded, for example, into Google Earth application for visualization.

<img src="./examples/data/california_roadmap.png" alt="California Road Network" width="350">

# See also

[California Road Network](https://users.cs.utah.edu/~lifeifei/SpatialDataset.htm)
Binary file added examples/data/california_roadmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static const constexpr char usage[] =
" edges path to the file with edges\n"
" nodes path to the file with nodes' coordinates\n"
" maxpaths the maximum number of paths to export\n"
" output the path to the output file.\n";
" output the path to the output KML file.\n";

int main(int argc, char **argv)
{
Expand Down

0 comments on commit 4f93782

Please sign in to comment.