Algorithm 1: Distance matrix generation

  1. Input:

    • List of all areas
    • All trips, grouped by trip start area
  2. N = len(all areas)

  3. Create a distance matrix Dis with dimensions [N][N]

  4. For each pair of areas (ai, aj) in all areas, do the following:

    • Get all trips from ai to aj from the dataset
    • Calculate the average distance of those trips
    • Set Dis[ai][aj] to the average distance
  5. For each pair of areas (ai, aj) in all areas, do the following:

    • If Dis[ai][aj] is NULL (i.e., no recorded trips), do the following:
      • Find all candidate paths from ai to aj using bidirectional search
      • Set Dis[ai][aj] to the minimum distance among all candidate paths
  6. Return the distance matrix Dis.

Distance Matrix Generation Algorithm: Efficiently Calculate Distances Between Areas

原文地址: https://www.cveoy.top/t/topic/m1iu 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录