Git Product home page Git Product logo

maps-pathfinding's Introduction

Comparing Algorithms: A* vs Dijkstra on the City's Map

This repository contains the code used in the YouTube video titled "Comparing Algorithms: A* vs Dijkstra, on the city's map". The video provides a visual comparison between the A* and Dijkstra algorithms in the context of finding paths on a city map represented as a graph.

Watch it here! (it's in spanish).

paragit

Introduction

The experiments conducted in the video can be easily reproduced by adding some image-saving logic to this notebook, ensuring that it saves each intermediate frame rather than just the final one. I opted against incorporating a comprehensive printing mechanism in the notebook to avoid unnecessary complexity and maintain clarity. However, if desired, implementing this feature is straightforward. The experiments conducted in the video are as follows:

Experiment 1: Pathfinding Efficiency

The first experiment focuses on comparing the efficiency of A* and Dijkstra algorithms. We measure the number of iterations each algorithm takes to find a path, and then analyze the distance, speed, and time of the reconstructed path. The visualization in the video illustrates the expansion of the algorithms from the origin to the destination, highlighting the roads considered during the process.

The conclusion drawn from this experiment is that although Dijkstra may take more iterations and yield a slightly longer path, it finds the absolute fastest path. On the other hand, A* is faster to execute but may not always produce the optimal path.

Experiment 2: Road Usage Analysis

In the second experiment, we conduct a deeper analysis of road usage by running an algorithm multiple times from random starting points. Each time the algorithm is run, we increment a counter for each road of the found path. Then we can plot a heatmap to see which roads were used the most by each algorithm.

The heatmap analysis reveals interesting observations. Dijkstra algorithm exhibits a tendency to prioritize highways and major roads due to their potential for faster routes to the destination. Conversely, A* algorithm might choose unconventional paths, prioritizing efficiency in reaching the destination during its execution. As a result, it may disregard deviations towards highways or main roads, despite their potential for faster travel, as they could lengthen the path.

How to use

This code relies on the osmnx library. Please refer to the osmnx documentation for installation instructions and detailed usage guidelines. Once installed, you can utilize all the functionalities provided in the notebook to reproduce the experiments conducted in the video and explore further analyses.

maps-pathfinding's People

Contributors

santifiorino 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.