/usr/share/doc/postgresql-9.5-pgrouting-doc/html/en/_sources/src/common/doc/functions/analyze_graph.txt is in postgresql-9.5-pgrouting-doc 2.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | ..
****************************************************************************
pgRouting Manual
Copyright(c) pgRouting Contributors
This documentation is licensed under a Creative Commons Attribution-Share
Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
****************************************************************************
.. _pgr_analyze_graph:
pgr_analyzeGraph
===============================================================================
.. index::
single: pgr_analyzeGraph(text,double precision,text,text,text,text,text)
module: common
Name
-------------------------------------------------------------------------------
``pgr_anlizeGraph`` — Analyzes the network topology.
Synopsis
-------------------------------------------------------------------------------
The function returns:
- ``OK`` after the analysis has finished.
- ``FAIL`` when the analysis was not completed due to an error.
.. code-block:: sql
varchar pgr_analyzeGraph(text edge_table, double precision tolerance,
text the_geom:='the_geom', text id:='id',
text source:='source',text target:='target',text rows_where:='true')
Description
-------------------------------------------------------------------------------
.. rubric:: Prerequisites
The edge table to be analyzed must contain a source column and a target column filled with id's of the vertices of the segments and the corresponding vertices table <edge_table>_vertices_pgr that stores the vertices information.
- Use :ref:`pgr_createVerticesTable <pgr_create_vert_table>` to create the vertices table.
- Use :ref:`pgr_createTopology <pgr_create_topology>` to create the topology and the vertices table.
.. rubric:: Parameters
The analyze graph function accepts the following parameters:
:edge_table: ``text`` Network table name. (may contain the schema name as well)
:tolerance: ``float8`` Snapping tolerance of disconnected edges. (in projection unit)
:the_geom: ``text`` Geometry column name of the network table. Default value is ``the_geom``.
:id: ``text`` Primary key column name of the network table. Default value is ``id``.
:source: ``text`` Source column name of the network table. Default value is ``source``.
:target: ``text`` Target column name of the network table. Default value is ``target``.
:rows_where: ``text`` Condition to select a subset or rows. Default value is ``true`` to indicate all rows.
The function returns:
- ``OK`` after the analysis has finished.
* Uses the vertices table: <edge_table>_vertices_pgr.
* Fills completly the ``cnt`` and ``chk`` columns of the vertices table.
* Returns the analysis of the section of the network defined by ``rows_where``
- ``FAIL`` when the analysis was not completed due to an error.
* The vertices table is not found.
* A required column of the Network table is not found or is not of the appropriate type.
* The condition is not well formed.
* The names of source , target or id are the same.
* The SRID of the geometry could not be determined.
.. rubric:: The Vertices Table
The vertices table can be created with :ref:`pgr_createVerticesTable <pgr_create_vert_table>` or :ref:`pgr_createTopology <pgr_create_topology>`
The structure of the vertices table is:
:id: ``bigint`` Identifier of the vertex.
:cnt: ``integer`` Number of vertices in the edge_table that reference this vertex.
:chk: ``integer`` Indicator that the vertex might have a problem.
:ein: ``integer`` Number of vertices in the edge_table that reference this vertex as incoming. See :ref:`pgr_analyzeOneway <pgr_analyze_oneway>`.
:eout: ``integer`` Number of vertices in the edge_table that reference this vertex as outgoing. See :ref:`pgr_analyzeOneway <pgr_analyze_oneway>`.
:the_geom: ``geometry`` Point geometry of the vertex.
.. rubric:: History
* New in version 2.0.0
Usage when the edge table's columns MATCH the default values:
-------------------------------------------------------------------------------
.. rubric:: The simplest way to use pgr_analyzeGraph is:
.. code-block:: sql
SELECT pgr_create_topology('edge_table',0.001);
SELECT pgr_analyzeGraph('edge_table',0.001);
.. rubric:: When the arguments are given in the order described in the parameters:
.. code-block:: sql
SELECT pgr_analyzeGraph('edge_table',0.001,'the_geom','id','source','target');
We get the same result as the simplest way to use the function.
.. warning:: | An error would occur when the arguments are not given in the appropriate order: In this example, the column ``id`` of the table ``mytable`` is passed to the function as the geometry column, and the geometry column ``the_geom`` is passed to the function as the id column.
| ``SELECT pgr_analyzeGraph('edge_table',0.001,'id','the_geom','source','target');``
| ERROR: Can not determine the srid of the geometry "id" in table public.edge_table
.. rubric:: When using the named notation
The order of the parameters do not matter:
.. code-block:: sql
SELECT pgr_analyzeGraph('edge_table',0.001,the_geom:='the_geom',id:='id',source:='source',target:='target');
.. code-block:: sql
SELECT pgr_analyzeGraph('edge_table',0.001,source:='source',id:='id',target:='target',the_geom:='the_geom');
Parameters defined with a default value can be ommited, as long as the value matches the default:
.. code-block:: sql
SELECT pgr_analyzeGraph('edge_table',0.001,source:='source');
.. rubric:: Selecting rows using rows_where parameter
Selecting rows based on the id. Displays the analysis a the section of the network.
.. code-block:: sql
SELECT pgr_analyzeGraph('edge_table',0.001,rows_where:='id < 10');
Selecting the rows where the geometry is near the geometry of row with ``id`` =5 .
.. code-block:: sql
SELECT pgr_analyzeGraph('edge_table',0.001,rows_where:='the_geom && (SELECT st_buffer(the_geom,0.05) FROM edge_table WHERE id=5)');
Selecting the rows where the geometry is near the geometry of the row with ``gid`` =100 of the table ``othertable``.
.. code-block:: sql
DROP TABLE IF EXISTS otherTable;
CREATE TABLE otherTable AS (SELECT 100 AS gid, st_point(2.5,2.5) AS other_geom) ;
SELECT pgr_analyzeGraph('edge_table',0.001,rows_where:='the_geom && (SELECT st_buffer(other_geom,1) FROM otherTable WHERE gid=100)');
Usage when the edge table's columns DO NOT MATCH the default values:
-------------------------------------------------------------------------------
For the following table
.. code-block:: sql
DROP TABLE IF EXISTS mytable;
CREATE TABLE mytable AS (SELECT id AS gid, source AS src ,target AS tgt , the_geom AS mygeom FROM edge_table);
SELECT pgr_createTopology('mytable',0.001,'mygeom','gid','src','tgt');
.. rubric:: Using positional notation:
The arguments need to be given in the order described in the parameters:
.. code-block:: sql
SELECT pgr_analyzeGraph('mytable',0.001,'mygeom','gid','src','tgt');
.. warning:: | An error would occur when the arguments are not given in the appropriate order: In this example, the column ``gid`` of the table ``mytable`` is passed to the function as the geometry column, and the geometry column ``mygeom`` is passed to the function as the id column.
| ``SELECT pgr_analyzeGraph('mytable',0.001,'gid','mygeom','src','tgt');``
| ERROR: Can not determine the srid of the geometry "gid" in table public.mytable
.. rubric:: When using the named notation
The order of the parameters do not matter:
.. code-block:: sql
SELECT pgr_analyzeGraph('mytable',0.001,the_geom:='mygeom',id:='gid',source:='src',target:='tgt');
.. code-block:: sql
SELECT pgr_analyzeGraph('mytable',0.001,source:='src',id:='gid',target:='tgt',the_geom:='mygeom');
In this scenario omitting a parameter would create an error because the default values for the column names do not match the column names of the table.
.. rubric:: Selecting rows using rows_where parameter
Selecting rows based on the id.
.. code-block:: sql
SELECT pgr_analyzeGraph('mytable',0.001,'mygeom','gid','src','tgt',rows_where:='gid < 10');
.. code-block:: sql
SELECT pgr_analyzeGraph('mytable',0.001,source:='src',id:='gid',target:='tgt',the_geom:='mygeom',rows_where:='gid < 10');
Selecting the rows WHERE the geometry is near the geometry of row with ``id`` =5 .
.. code-block:: sql
SELECT pgr_analyzeGraph('mytable',0.001,'mygeom','gid','src','tgt',
rows_where:='mygeom && (SELECT st_buffer(mygeom,1) FROM mytable WHERE gid=5)');
.. code-block:: sql
SELECT pgr_analyzeGraph('mytable',0.001,source:='src',id:='gid',target:='tgt',the_geom:='mygeom',
rows_where:='mygeom && (SELECT st_buffer(mygeom,1) FROM mytable WHERE gid=5)');
Selecting the rows WHERE the geometry is near the place='myhouse' of the table ``othertable``. (note the use of quote_literal)
.. code-block:: sql
DROP TABLE IF EXISTS otherTable;
CREATE TABLE otherTable AS (SELECT 'myhouse'::text AS place, st_point(2.5,2.5) AS other_geom) ;
SELECT pgr_analyzeGraph('mytable',0.001,'mygeom','gid','src','tgt',
rows_where:='mygeom && (SELECT st_buffer(other_geom,1) FROM otherTable WHERE place='||quote_literal('myhouse')||')');
.. code-block:: sql
SELECT pgr_analyzeGraph('mytable',0.001,source:='src',id:='gid',target:='tgt',the_geom:='mygeom',
rows_where:='mygeom && (SELECT st_buffer(other_geom,1) FROM otherTable WHERE place='||quote_literal('myhouse')||')');
Examples
-------------------------------------------------------------------------------
.. code-block:: sql
SELECT pgr_create_topology('edge_table',0.001);
SELECT pgr_analyzeGraph('edge_table', 0.001);
NOTICE: PROCESSING:
NOTICE: pgr_analyzeGraph('edge_table',0.001,'the_geom','id','source','target','true')
NOTICE: Performing checks, pelase wait...
NOTICE: Analyzing for dead ends. Please wait...
NOTICE: Analyzing for gaps. Please wait...
NOTICE: Analyzing for isolated edges. Please wait...
NOTICE: Analyzing for ring geometries. Please wait...
NOTICE: Analyzing for intersections. Please wait...
NOTICE: ANALYSIS RESULTS FOR SELECTED EDGES:
NOTICE: Isolated segments: 2
NOTICE: Dead ends: 7
NOTICE: Potential gaps found near dead ends: 1
NOTICE: Intersections detected: 1
NOTICE: Ring geometries: 0
pgr_analizeGraph
--------------------
OK
(1 row)
SELECT pgr_analyzeGraph('edge_table',0.001,rows_where:='id < 10');
NOTICE: PROCESSING:
NOTICE: pgr_analyzeGraph('edge_table',0.001,'the_geom','id','source','target','id < 10')
NOTICE: Performing checks, pelase wait...
NOTICE: Analyzing for dead ends. Please wait...
NOTICE: Analyzing for gaps. Please wait...
NOTICE: Analyzing for isolated edges. Please wait...
NOTICE: Analyzing for ring geometries. Please wait...
NOTICE: Analyzing for intersections. Please wait...
NOTICE: ANALYSIS RESULTS FOR SELECTED EDGES:
NOTICE: Isolated segments: 0
NOTICE: Dead ends: 4
NOTICE: Potential gaps found near dead ends: 0
NOTICE: Intersections detected: 0
NOTICE: Ring geometries: 0
pgr_analizeGraph
--------------------
OK
(1 row)
SELECT pgr_analyzeGraph('edge_table',0.001,rows_where:='id >= 10');
NOTICE: PROCESSING:
NOTICE: pgr_analyzeGraph('edge_table',0.001,'the_geom','id','source','target','id >= 10')
NOTICE: Performing checks, pelase wait...
NOTICE: Analyzing for dead ends. Please wait...
NOTICE: Analyzing for gaps. Please wait...
NOTICE: Analyzing for isolated edges. Please wait...
NOTICE: Analyzing for ring geometries. Please wait...
NOTICE: Analyzing for intersections. Please wait...
NOTICE: ANALYSIS RESULTS FOR SELECTED EDGES:
NOTICE: Isolated segments: 2
NOTICE: Dead ends: 8
NOTICE: Potential gaps found near dead ends: 1
NOTICE: Intersections detected: 1
NOTICE: Ring geometries: 0
pgr_analizeGraph
--------------------
OK
(1 row)
-- Simulate removal of edges
SELECT pgr_createTopology('edge_table', 0.001,rows_where:='id <17');
SELECT pgr_analyzeGraph('edge_table', 0.001);
NOTICE: PROCESSING:
NOTICE: pgr_analyzeGraph('edge_table',0.001,'the_geom','id','source','target','true')
NOTICE: Performing checks, pelase wait...
NOTICE: Analyzing for dead ends. Please wait...
NOTICE: Analyzing for gaps. Please wait...
NOTICE: Analyzing for isolated edges. Please wait...
NOTICE: Analyzing for ring geometries. Please wait...
NOTICE: Analyzing for intersections. Please wait...
NOTICE: ANALYSIS RESULTS FOR SELECTED EDGES:
NOTICE: Isolated segments: 0
NOTICE: Dead ends: 3
NOTICE: Potential gaps found near dead ends: 0
NOTICE: Intersections detected: 0
NOTICE: Ring geometries: 0
pgr_analizeGraph
--------------------
OK
(1 row)
SELECT pgr_createTopology('edge_table', 0.001,rows_where:='id <17');
NOTICE: PROCESSING:
NOTICE: pgr_createTopology('edge_table',0.001,'the_geom','id','source','target','id <17')
NOTICE: Performing checks, pelase wait .....
NOTICE: Creating Topology, Please wait...
NOTICE: -------------> TOPOLOGY CREATED FOR 16 edges
NOTICE: Rows with NULL geometry or NULL id: 0
NOTICE: Vertices table for table public.edge_table is: public.edge_table_vertices_pgr
NOTICE: ----------------------------------------------
pgr_analizeGraph
--------------------
OK
(1 row)
SELECT pgr_analyzeGraph('edge_table', 0.001);
NOTICE: PROCESSING:
NOTICE: pgr_analyzeGraph('edge_table',0.001,'the_geom','id','source','target','true')
NOTICE: Performing checks, pelase wait...
NOTICE: Analyzing for dead ends. Please wait...
NOTICE: Analyzing for gaps. Please wait...
NOTICE: Analyzing for isolated edges. Please wait...
NOTICE: Analyzing for ring geometries. Please wait...
NOTICE: Analyzing for intersections. Please wait...
NOTICE: ANALYSIS RESULTS FOR SELECTED EDGES:
NOTICE: Isolated segments: 0
NOTICE: Dead ends: 3
NOTICE: Potential gaps found near dead ends: 0
NOTICE: Intersections detected: 0
NOTICE: Ring geometries: 0
pgr_analizeGraph
--------------------
OK
(1 row)
The examples use the :ref:`sampledata` network.
See Also
-------------------------------------------------------------------------------
* :ref:`topology` for an overview of a topology for routing algorithms.
* :ref:`pgr_analyze_oneway` to analyze directionality of the edges.
* :ref:`pgr_createVerticesTable <pgr_create_vert_table>` to reconstruct the vertices table based on the source and target information.
* :ref:`pgr_nodeNetwork <pgr_node_network>` to create nodes to a not noded edge table.
|