Manhattan Distance

Author: Ernad Mujakic
Date: 2025-07-31


The Manhattan distance is a Distance Measure defined as the sum of the absolute differences of the Cartesian coordinates of two points. It is the distance between two points using only grid-like movements (horizontal and vertical). The Manhattan distance is also the norm of the distance between two vectors in Lp Space.

The Manhattan distance between two objects in -dimensional space is calculated as:

Properties

  • Positive: Like any other distance metric, the range of the Manhattan distance is where a 0 distance indicates that the two points are at the same location.
  • Symmetric: The Manhattan distance is symmetric, meaning
  • Triangle Inequality: The Manhattan distance obeys the triangle inequality, which states that the distance from to is always less than or equal to the distance from to plus the distance from to . Meaning that taking a detour through a third point cannot result in a shorter distance than a direct path from to .

Applications

  • Measuring Pixel Differences: The Manhattan distance, or other distance measures, may be employed to compare pixel values, or features in image recognition tasks.

Pathfinding

  • The Manhattan distance can be used for calculating the shortest path between points. It is also an Admissible and Consistent Heuristic in search algorithms such as A* Search.
  • Grid-Navigation: The Manhattan distance is particularly useful for pathfinding in domains which only allow grid-like movements, such as a chessboard or a city network.

Statistics

  • Outlier Detection: Manhattan distance can be used for distance based outlier detection algorithms such as DBSCAN.
  • Multidimensional Scaling: Manhattan distance may be employed to visualize higher-dimensional data into lower dimensions.

Other Distance Measures

Other common distance measures include:

  • Euclidean Distance: The straight-line distance between 2 points in Euclidean space.
  • Chebyshev Distance: The maximum absolute difference between 2 vectors across all dimensions.
  • Minkowski Distance: A generalized distance measure that is defined by a parameter whose common values are the Manhattan distance, Euclidean distance, and Chebyshev distance.
  • Jaccard Index: Used to compare sets and is defined as the size of the intersection of 2 sets, over the size of their union.

References