pgr_makeConnected - Experimental

pgr_makeConnected — Returns the set of edges that will make the graph connected.

_images/boost-inside.jpeg

Boost Graph Inside

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.2.0

    • New experimental function

Description

Adds the minimum number of edges needed to make the input graph connected. The algorithm first identifies all of the connected components in the graph, then adds edges to connect those components together in a path. For example, if a graph contains three connected components A, B, and C, make_connected will add two edges. The two edges added might consist of one connecting a vertex in A with a vertex in B and one connecting a vertex in B with a vertex in C.

The main characteristics are:
  • It will give the minimum list of all edges which are needed in the graph to make the graph connected.

  • Applicable only for undirected graphs.

  • The algorithm does not considers traversal costs in the calculations.

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

Signatures

Summary

pgr_makeConnected(Edges SQL)

RETURNS SET OF (seq, start_vid, end_vid)
OR EMPTY SET
Example

Query done on Sample Data network gives the list of edges that are needed in the graph to make it connected.

SELECT * FROM pgr_makeConnected(
    'SELECT id, source, target, cost, reverse_cost
     FROM edge_table'
);
 seq | start_vid | end_vid
-----+-----------+---------
   1 |        13 |      14
   2 |        15 |      16
(2 rows)

Parameters

Parameter

Type

Default

Description

Edges SQL

TEXT

SQL query as described below.

Inner query

Edges SQL

an SQL query, which should return a set of rows 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

  • When positive: edge (target, source) is part of the graph.

  • When negative: edge (target, source) is not part of the graph.

reverse_cost

ANY-NUMERICAL

-1

  • When positive: edge (target, source) is part of the graph.

  • When negative: edge (target, source) is not part of the graph.

Where:

ANY-INTEGER

SMALLINT, INTEGER, BIGINT

ANY-NUMERICAL

SMALLINT, INTEGER, BIGINT, REAL, FLOAT

Result Columns

Returns set of (seq, start_vid, end_vid)

Column

Type

Description

seq

INT

Sequential value starting from 1.

start_vid

BIGINT

Identifier of the first end point vertex of the edge.

end_vid

BIGINT

Identifier of the second end point vertex of the edge.

See Also

Indices and tables