pgr_biconnectedComponents
— Return the biconnected components of an undirected graph.
In particular, the algorithm implemented by Boost.Graph.
Warning
Experimental functions
The biconnected components of an undirected graph are the maximal subsets of vertices such that the removal of a vertex from particular component will not disconnect the component. Unlike connected components, vertices may belong to multiple biconnected components. Vertices can be present in multiple biconnected components, but each edge can only be contained in a single biconnected component. So, the output only has edge version.
This implementation can only be used with an undirected graph.
The main Characteristics are:
- Components are described by edges
- The returned values are ordered:
- component ascending
- edge ascending
- Running time: \(O(V + E)\)
pgr_biconnectedComponents(edges_sql)
RETURNS SET OF (seq, component, n_seq, edge)
OR EMPTY SET
The signature is for a undirected graph.
Example: |
---|
SELECT * FROM pgr_biconnectedComponents(
'SELECT id, source, target, cost, reverse_cost FROM edge_table'
);
seq | component | n_seq | edge
-----+-----------+-------+------
1 | 1 | 1 | 1
2 | 2 | 1 | 2
3 | 2 | 2 | 3
4 | 2 | 3 | 4
5 | 2 | 4 | 5
6 | 2 | 5 | 8
7 | 2 | 6 | 9
8 | 2 | 7 | 10
9 | 2 | 8 | 11
10 | 2 | 9 | 12
11 | 2 | 10 | 13
12 | 2 | 11 | 15
13 | 2 | 12 | 16
14 | 6 | 1 | 6
15 | 7 | 1 | 7
16 | 14 | 1 | 14
17 | 17 | 1 | 17
18 | 18 | 1 | 18
(18 rows)
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 |
Weight of the edge (source, target)
|
|
reverse_cost | ANY-NUMERICAL |
-1 | Weight of the edge (target, source),
|
Where:
ANY-INTEGER: | SMALLINT, INTEGER, BIGINT |
---|---|
ANY-NUMERICAL: | SMALLINT, INTEGER, BIGINT, REAL, FLOAT |
Parameter | Type | Default | Description |
---|---|---|---|
edges_sql | TEXT |
SQL query as described above. |
Returns set of (seq, component, n_seq, edge)
Column | Type | Description |
---|---|---|
seq | INT |
Sequential value starting from 1. |
component | BIGINT |
Component identifier. It is equal to the minimum edge identifier in the component. |
n_seq | INT |
It is a sequential value starting from 1 in a component. |
edge | BIGINT |
Identifier of the edge. |
Indices and tables