This repository has been archived by the owner on Mar 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
3. Do graph analysis
agouge edited this page Feb 15, 2013
·
31 revisions
We do the actual graph analysis on connected component 1 as follows:
EXECUTE ST_GraphAnalysis(routes_1.edges, 'weight', 'routes_1', 3);
Please see the Javadoc for ST_GraphAnalysis
(pending) for an explanation of the parameters. The default output table prefix is output
.
This produces a table routes.graph_analysis
containing
-
id
The node id -
betweenness_centrality
Betweenness centrality -
closeness_centrality
Closeness centrality
We could just as easily consider the graph to be unweighted bidirectional:
EXECUTE ST_GraphAnalysis(routes_1.edges, 1, 'routes_1_unweighted', 3);
It remains only to match the node ids with their geometries in routes.nodes
(or in routes_1.nodes
).
CREATE TABLE routes_1.graph_analysis AS SELECT a.the_geom, b.* FROM routes.nodes a, routes_1.graph_analysis b WHERE a.id=b.id;
For unweighted graphs:
CREATE TABLE routes_1_unweighted.graph_analysis AS SELECT a.the_geom, b.* FROM routes.nodes a, routes_1_unweighted.graph_analysis b WHERE a.id=b.id;
Here we get rid of intermediate tables we no longer need:
DROP TABLE routes_1.nodes PURGE;
DROP TABLE routes_1_start.edges PURGE;
DROP TABLE routes_1_end.edges PURGE;
DROP TABLE routes_1.edges PURGE;
DROP TABLE routes_1_tmp.graph_analysis PURGE;