Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

Graph analysis on a transportation network

Adam Gouge edited this page Oct 15, 2013 · 20 revisions

Algorithms used

Underneath the hood, ST_GraphAnalysis uses a modified version of Dijkstra's algorithm (for weighted graphs) or Breadth First Search (BFS) (for unweighted graphs--generally much faster!) to calculate, for a given node, this shortest distance to every other node, as well as the number of shortest paths to every other node. Betweenness (and closeness) centrality indices are calculated using Brande's algorithm (A faster algorithm for betweenness centrality, 2001). This algorithm evaluates in O( nm ) time for unweighted graphs and O( nm+n^2 log n ) time for weighted graphs, where n is the number of nodes and m is the number of edges.

Weighted vs. unweighted

The user may consider the graph to be unweighted (equivalently, all edge weights are equal to 1) or weighted. If the graph is weighted, the user must specify the weights (e.g., distance, cost, etc.).

Orientation

The user is asked to specify the orientation of the graph by a given integer:

  • 1 Directed
  • 2 Reversed (directed with all edge orientations reversed)
  • 3 Bidirectional (equivalently: undirected)

Estimated computation times

The following are estimated computation times on the road networks of the given geographical regions computed on a 64-bit Dell Latitude E6500 running Arch Linux.

First letter:

  • W = Weighted
  • U = Unweighted

Second letter:

  • D = Directed
  • U = Undirected
Graph Nodes Edges UU WU UD WD
Nantes 17 611 23 482 20m 20m 19m30s 19m30s

This example

We will do graph analysis on an input table named routes. The input table must contain a column the_geom of one-dimensional geometries (such as MULTILINESTRINGs). For illustration purposes, in this guide we will consider the graph to be bidirectional.