pgr_chinesePostman - Experimental

pgr_chinesePostman — Calculates the shortest circuit path which contains every edge in a directed graph and starts and ends on the same vertex.

Warning

Possible server crash

  • These functions might create a server crash

Warning

Experimental functions

  • They are not officially of the current release.

  • They likely will not be officially be part of the next release:

    • The functions might not make use of ANY-INTEGER and ANY-NUMERICAL

    • Name might change.

    • Signature might change.

    • Functionality might change.

    • pgTap tests might be missing.

    • Might need c/c++ coding.

    • May lack documentation.

    • Documentation if any might need to be rewritten.

    • Documentation examples might need to be automatically generated.

    • Might need a lot of feedback from the comunity.

    • Might depend on a proposed function of pgRouting

    • Might depend on a deprecated function of pgRouting

Availability

  • Version 3.0.0

    • New experimental function

Support

  • Supported versions current(3.1) 3.0

Description

The main characteristics are:

  • Process is done only on edges with positive costs.

  • Running time: \(O(E * (E + V * logV))\)

  • Graph must be connected.

  • Returns EMPTY SET on a disconnected graph

Signatures

pgr_chinesePostman(edges_sql)
RETURNS SET OF (seq, node, edge, cost, agg_cost)
OR EMPTY SET
Example

SELECT * FROM pgr_chinesePostman(
    'SELECT id,
     source, target,
     cost, reverse_cost FROM edge_table where id < 17'
);
 seq | node | edge | cost | agg_cost
-----+------+------+------+----------
   1 |   -1 |   -1 |   34 |       34
   2 |    3 |    2 |    1 |        1
   3 |    2 |    1 |    1 |        2
   4 |    1 |    1 |    1 |        3
   5 |    2 |    4 |    1 |        4
   6 |    5 |    4 |    1 |        5
   7 |    2 |    4 |    1 |        6
   8 |    5 |    7 |    1 |        7
   9 |    8 |    6 |    1 |        8
  10 |    7 |    6 |    1 |        9
  11 |    8 |    7 |    1 |       10
  12 |    5 |    8 |    1 |       11
  13 |    6 |    8 |    1 |       12
  14 |    5 |   10 |    1 |       13
  15 |   10 |   10 |    1 |       14
  16 |    5 |   10 |    1 |       15
  17 |   10 |   14 |    1 |       16
  18 |   13 |   14 |    1 |       17
  19 |   10 |   12 |    1 |       18
  20 |   11 |   13 |    1 |       19
  21 |   12 |   15 |    1 |       20
  22 |    9 |    9 |    1 |       21
  23 |    6 |    9 |    1 |       22
  24 |    9 |   15 |    1 |       23
  25 |   12 |   15 |    1 |       24
  26 |    9 |   16 |    1 |       25
  27 |    4 |   16 |    1 |       26
  28 |    9 |   16 |    1 |       27
  29 |    4 |    3 |    1 |       28
  30 |    3 |    5 |    1 |       29
  31 |    6 |   11 |    1 |       30
  32 |   11 |   13 |    1 |       31
  33 |   12 |   15 |    1 |       32
  34 |    9 |   16 |    1 |       33
  35 |    4 |   -1 |    0 |       34
(35 rows)

Parameters

Column

Type

Default

Description

edges_sql

TEXT

The edges SQL query as described in Inner query.

Inner query

An Edges SQL that represents a directed graph with the following columns

Column

Type

Default

Description

id

ANY-INTEGER

Identifier of the edge.

source

ANY-INTEGER

Identifier of the first end point vertex of the edge.

target

ANY-INTEGER

Identifier of the second end point vertex of the edge.

cost

ANY-NUMERICAL

Weight of the edge (source, target)

  • When negative: edge (source, target) does not exist, therefore it’s not part of the graph.

reverse_cost

ANY-NUMERICAL

-1

Weight of the edge (target, source),

  • When negative: edge (target, source) does not exist, therefore it’s not part of the graph.

Where:

ANY-INTEGER

SMALLINT, INTEGER, BIGINT

ANY-NUMERICAL

SMALLINT, INTEGER, BIGINT, REAL, FLOAT

Result Columns

Returns set of (seq, node, edge, cost, agg_cost)

Column

Type

Description

seq

INT

Sequential value starting from 1.

node

BIGINT

Identifier of the node in the path from start_vid to end_vid.

edge

BIGINT

Identifier of the edge used to go from node to the next node in the path sequence. -1 for the last node of the path.

cost

FLOAT

Cost to traverse from node using edge to the next node in the path sequence.

agg_cost

FLOAT

Aggregate cost from start_v to node.