pgr_lineGraph - Experimental¶
pgr_lineGraph
— Transforms the given graph into its corresponding edge-based
graph.
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 2.5.0
New Experimental function
Description¶
Given a graph \(G\), its line graph \(L(G)\) is a graph such that:
Each vertex of \(L(G)\) represents an edge of \(G\).
Two vertices of \(L(G)\) are adjacent if and only if their corresponding edges share a common endpoint in \(G\)
The main characteristics are:
Works for directed and undirected graphs.
The
cost
andreverse_cost
columns of the result represent existence of the edge.When the graph is directed the result is directed.
When the graph is undirected the result is undirected.
The
reverse_cost
is always \(-1\).
Signatures¶
directed
])(seq, source, target, cost, reverse_cost)
- Example:
For an undirected graph with edges :math:’{2,4,5,8}’
SELECT * FROM pgr_lineGraph(
'SELECT id, source, target, cost, reverse_cost FROM edges'
);
seq | source | target | cost | reverse_cost
-----+--------+--------+------+--------------
1 | -18 | 18 | 1 | 1
2 | -17 | 17 | 1 | 1
3 | -16 | -3 | 1 | -1
4 | -14 | -10 | 1 | 1
5 | -14 | 12 | 1 | -1
6 | -14 | 14 | 1 | 1
7 | -10 | -7 | 1 | 1
8 | -10 | -4 | 1 | 1
9 | -10 | 8 | 1 | 1
10 | -10 | 10 | 1 | 1
11 | -9 | -8 | 1 | 1
12 | -9 | 9 | 1 | 1
13 | -9 | 11 | 1 | -1
14 | -8 | -7 | 1 | 1
15 | -8 | -4 | 1 | 1
16 | -8 | 8 | 1 | 1
17 | -7 | -6 | 1 | 1
18 | -7 | 7 | 1 | 1
19 | -6 | 6 | 1 | 1
20 | -3 | -2 | 1 | -1
21 | -3 | 5 | 1 | -1
22 | -2 | -1 | 1 | -1
23 | -2 | 4 | 1 | -1
24 | 1 | -1 | 1 | 1
25 | 1 | 4 | 1 | 1
26 | 4 | -7 | 1 | 1
27 | 4 | -4 | 1 | 1
28 | 5 | -8 | 1 | -1
29 | 5 | 9 | 1 | -1
30 | 5 | 11 | 1 | -1
31 | 8 | 11 | 1 | -1
32 | 9 | -16 | 1 | 1
33 | 9 | 15 | 1 | 1
34 | 10 | 12 | 1 | -1
35 | 11 | 13 | 1 | -1
36 | 12 | 13 | 1 | -1
37 | 13 | -15 | 1 | -1
38 | 15 | -15 | 1 | 1
39 | 16 | -16 | 1 | 1
40 | 16 | 15 | 1 | 1
(40 rows)
Parameters¶
Parameter |
Type |
Description |
---|---|---|
|
Edges SQL as described below. |
Optional parameters¶
Column |
Type |
Default |
Description |
---|---|---|---|
|
|
|
|
Inner Queries¶
Edges SQL¶
Column |
Type |
Default |
Description |
---|---|---|---|
|
ANY-INTEGER |
Identifier of the edge. |
|
|
ANY-INTEGER |
Identifier of the first end point vertex of the edge. |
|
|
ANY-INTEGER |
Identifier of the second end point vertex of the edge. |
|
|
ANY-NUMERICAL |
Weight of the edge ( |
|
|
ANY-NUMERICAL |
-1 |
Weight of the edge (
|
Where:
- ANY-INTEGER:
SMALLINT
,INTEGER
,BIGINT
- ANY-NUMERICAL:
SMALLINT
,INTEGER
,BIGINT
,REAL
,FLOAT
Result columns¶
Returns set of (seq, source, target, cost, reverse_cost)
Column |
Type |
Description |
---|---|---|
|
|
Sequential value starting from 1.
|
|
|
Identifier of the source vertex of the current edge.
|
|
|
Identifier of the target vertex of the current edge.
|
|
|
Weight of the edge (
|
|
|
Weight of the edge (
|
See Also¶
wikipedia: Line Graph
mathworld: Line Graph
Indices and tables