This repository was 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
1. Construct the graph
agouge edited this page Feb 15, 2013
·
10 revisions
First we build the graph where the edges are roads and the nodes are intersections by executing the following instruction on the input table routes:
EXECUTE ST_Graph(routes, 0.01, false, 'routes');Please see the Javadoc for ST_Graph for an explanation of the parameters.
The two resulting output tables will be named routes.nodes and routes.edges. By default, routes.edges conserves all the columns in routes while appending three columns:
-
idEdge id -
start_nodeId for each start node -
end_nodeId for each end node
On the other hand, routes.nodes contains two columns:
-
the_geomThePOINTgeometry of each intersection -
idThe node id.
If the graph is to be weighted, we have to specify the edge weights in an additional column of routes.edges. Any nonnegative double value can be used.
For example, we could use the length of each edge as the edge weight as follows:
ALTER TABLE routes.edges ADD COLUMN weight double;
UPDATE routes.edges SET weight=ST_Length(the_geom);