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

3. Do graph analysis

agouge edited this page Feb 14, 2013 · 31 revisions

Weighted

We do the actual graph analysis on connected component 1 as follows:

EXECUTE ST_GraphAnalysis(routes_1.edges, 'weight', 'routes', 3);

Please see the Javadoc for ST_GraphAnalysis (pending) for an explanation of the parameters.

This produces a table routes.graph_analysis containing

  • id The node id
  • betweenness_centrality Betweenness centrality
  • closeness_centrality Closeness centrality

Underneath the hood, this function uses a modified version of Dijkstra's algorithm to calculate, for a given fixed node, this shortest distance to every other node, as well as the number of shortest paths to every other node.

Unweighted

We could just as easily consider the graph to be unweighted bidirectional:

EXECUTE ST_GraphAnalysis(routes_1.edges, 1, 'routes_unweighted', 3);