Code Monkey home page Code Monkey logo

hierarchical-pathfinding's Introduction

Hierarchical Pathfinding

Hierarchical pathfinding is a technique that provides a way to navigate on different levels of road network. This is accomplished using node clustering and precomputing optimal paths within clusters. Hierarchical pathfinding significantly increases pathfinding speed. For example, to find a route from Madrid To Barcelona, A* algorithm would not discover every edge in-between, but focus on pathfinding among clusters (districts and/or cities).

Performance

Dataset: Helsinki road network (5750 nodes, 13364 edges, 26 clusters).
Clusters visualization can be found below.
Computing distance matrix for n random nodes:

n Without clustering With clustering
25 7441 ms 6671 ms
50 8473 ms 6958 ms
100 28338 ms 20284 ms

Documentation

#include "graph.h"
class Graph;

Class representing clusterized directed weighted graph.

#include "graph.h"
Graph from_graphml(const std::string&);

Create Graph object form GraphML file. < key > tag attributes required: "x" (lon), "y" (lat), "length" (weight).

#include "graph.h"
void clusterize(double threshold);

Clusterize graph nodes and precompute optimal paths within clusters. Threshold is set in kilometers. Iterative algorithm, merges clusters 20 times, removing small clusters in the end. Haversine is used as a distance function.

#include "graph.h"
Path find_path_astar(uint64_t start, uint64_t goal, const Graph&,
                     bool use_clusters = true, double heuristic_multiplier = 100);

Find a path between start and goal nodes (by ID). Uses A* algorithm with binary heap as a data structure. The higher heuristic_multiplier, the more heuristic-focused search will be.

#include "path.h"
void to_gpx(uint64_t, const std::string&, const node_map*) const;

Export path to GPX file as a track. Start node of a path is required (by ID), since it is not stored in an object. node_map can be obtained using Graph::get_nodes().

#include "graph.h"
size_t cluster_count() const;

Return number of precomputed clusters.

#include "graph.h"
void export_nodes(const std::string&) const;

Export node data to CSV file. It can be further visualized using plot_nodes.py script:

python plot_nodes.py nodes.csv clusters.html

The data can also be visualized (put on the map) using geopandas.GeoDataFrame.explore().

Future development

  • Multilevel clustering
  • Polygonal clustering
  • Edge-based clustering
  • DOT, JSON, BOOST input formats

hierarchical-pathfinding's People

Contributors

denikozub avatar whitewolfgeralt avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.