City Distance Tools

CITIES is a FORTRAN90 library which works with problems involving intercity distances.

Such problems include:


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


CITIES is available in a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

ASA058, a FORTRAN90 library which contains the original text of the Sparks clustering algorithm.

ASA136, a FORTRAN90 library which implements the K-Means algorithm.

CITIES, a dataset directory which contains a number of city distance datasets.

DISTANCE_TO_POSITION, a FORTRAN90 program which estimates the positions of cities based on a city-to-city distance table.

DISTANCE_TO_POSITION_SPHERE, a MATLAB program which estimates the positions of cities on a sphere (such as the earth) based on a city-to-city distance table.

FLOYD, a FORTRAN90 library which implements Floyd's algorithm for finding the shortest distance between pairs of nodes on a directed graph.

GRAPH_REPRESENTATION, a data directory which contains examples of ways of representing abstract mathematical graphs

KMEANS, a FORTRAN90 library which treats the K-means problem of grouping a discrete set of N points into K clusters.

LAU_NP, a FORTRAN90 library which includes heuristic approaches to certain NP-complete problems, including the traveling salesman problem, the K-center problem and the K-median problem.

POINT_MERGE, a FORTRAN90 library which considers N points in M dimensional space, and counts or indexes the unique or "tolerably unique" items.

SPAETH, a FORTRAN90 library which can cluster data according to various principles.

SPAETH, a dataset collection which contains a set of test data.

SPAETH2, a FORTRAN90 library which can cluster data according to various principles.

SPAETH2, a dataset collection which contains a set of test data.

TOMS456, a FORTRAN77 library which solves the routing problem, connecting some nodes in a network.

TSP, a dataset directory which contains test data for the traveling salesperson problem;

TSP_BRUTE, a FORTRAN90 program which reads a file of city-to-city distances and solves the traveling salesperson problem, using brute force.


  1. Franz Aurenhammer,
    Voronoi diagrams - a study of a fundamental geometric data structure,
    ACM Computing Surveys,
    Volume 23, Number 3, pages 345-405, September 1991.
  2. John Burkardt, Max Gunzburger, Janet Peterson, Rebecca Brannon,
    User Manual and Supporting Information for Library of Codes for Centroidal Voronoi Placement and Associated Zeroth, First, and Second Moment Determination,
    Sandia National Laboratories Technical Report SAND2002-0099,
    February 2002.
  3. Marc de Berg, Marc Krevald, Mark Overmars, Otfried Schwarzkopf,
    Computational Geometry,
    Springer, 2000.
  4. Qiang Du, Vance Faber, Max Gunzburger,
    Centroidal Voronoi Tessellations: Applications and Algorithms,
    SIAM Review, Volume 41, 1999, pages 637-676.
  5. Alan Gibbons,
    Algorithmic Graph Theory,
    Cambridge University Press, 1985.
  6. John Hartigan, M A Wong,
    Algorithm AS 136: A K-Means Clustering Algorithm,
    Applied Statistics,
    Volume 28, Number 1, 1979, pages 100-108.
  7. Barry Joe,
    GEOMPACK - a software package for the generation of meshes using geometric algorithms,
    Advances in Engineering Software,
    Volume 13, pages 325-331, 1991.
  8. Hang Tong Lau,
    Algorithms on Graphs,
    Tab Books, 1989.
  9. Atsuyuki Okabe, Barry Boots, Kokichi Sugihara, Sung Nok Chiu,
    Spatial Tesselations: Concepts and Applications of Voronoi Diagrams,
    Second Edition,
    Wiley, 2000.
  10. Joseph O'Rourke,
    Computational Geometry,
    Cambridge University Press,
    Second Edition, 1998.
  11. Helmut Spaeth,
    Cluster Analysis Algorithms for Data Reduction and Classification of Objects,
    Ellis Horwood, 1980.
  12. David Sparks,
    Algorithm AS 58: Euclidean Cluster Analysis,
    Applied Statistics,
    Volume 22, Number 1, 1973,
    pages 126-130.

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the FORTRAN90 source codes.

Last revised on 19 May 2016.