pgr_edgeColoring - Experimental - pgRouting Manual (3.3)

pgr_edgeColoring - Experimental
pgr_edgeColoring
- Returns the edge coloring of an undirected and loop-free (i.e
no self-loops and no parallel edges
) 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 3.3.0
-
New experimental function
-
Description
Edge Coloring is an algorithm used for coloring of the edges for the vertices in the graph. It is an assignment of colors to the edges of the graph so that no two adjacent edges have the same color.
The main Characteristics are:
-
The implementation is applicable only for undirected and loop-free (i.e no self-loops and no parallel edges ) graphs.
-
Provides the color to be assigned to all the edges present in the graph.
-
At most Δ + 1 colors are used, where Δ is the degree of the graph. This is optimal for some graphs, and by Vizing’s theorem it uses at most one color more than the optimal for all others.
-
It can tell us whether a graph is Bipartite . If in a graph, the chromatic number χ′(G) i.e. minimum number of colors needed for proper edge coloring of graph is equal to degree Δ of the graph, (i.e. χ′(G) = Δ ) then graph is said to be Bipartite. But, the vice-versa is not always true.
-
The algorithm tries to assign the least possible color to every edge.
-
Efficient graph coloring is an NP-Hard problem, and therefore, this algorithm does not always produce optimal coloring.
-
The returned rows are ordered in ascending order of the edge value.
-
This algorithm is the fastest known almost-optimal algorithm for edge coloring.
-
Edge Coloring Running Time: \(O(EV)\)
-
where \(E\) is the number of edges in the graph,
-
\(V\) is the number of vertices in the graph.
-
Signatures
pgr_edgeColoring(Edges SQL)
RETURNS SET OF (edge_id, color_id)
OR EMPTY SET
- Example :
-
Graph coloring of pgRouting Sample Data
SELECT * FROM pgr_edgeColoring(
'SELECT id, source, target, cost, reverse_cost FROM edge_table
ORDER BY id'
);
edge_id color_id
---------+----------
1 3
2 2
3 3
4 4
5 4
6 1
7 2
8 1
9 2
10 5
11 5
12 3
13 2
14 1
15 3
16 1
17 1
18 1
(18 rows)
Parameters
Parameter |
Type |
Description |
---|---|---|
Edges SQL |
|
Inner query as described below. |
Inner query
- Edges SQL :
-
an SQL query of an undirected graph, which should return a set of rows with the following columns:
Column |
Type |
Default |
Description |
---|---|---|---|
id |
|
Identifier of the edge. |
|
source |
|
Identifier of the first end point vertex of the edge. |
|
target |
|
Identifier of the second end point vertex of the edge. |
|
cost |
|
|
|
reverse_cost |
|
-1 |
|
Where:
- ANY-INTEGER :
-
SMALLINT, INTEGER, BIGINT
- ANY-NUMERICAL :
-
SMALLINT, INTEGER, BIGINT, REAL, FLOAT
Result Columns
Returns SET OF
(edge_id,
color_id)
Column |
Type |
Description |
---|---|---|
edge_id |
|
Identifier of the edge. |
color_id |
|
Identifier of the color of the edge.
|
See Also
-
The queries use the Sample Data network.
Indices and tables