pgr_edgeColoring  Experimental¶
pgr_edgeColoring
— Returns the edge coloring of undirected and loopfree
graphs
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 ANYINTEGER and ANYNUMERICAL
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 signature
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 for undirected and loopfree graphs
 loop free:
no selfloops and no parallel edges.
Provides the color to be assigned to all the edges present in the graph.
At most \(\Delta + 1\) colors are used, where \(\Delta\) 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.
When the graph is bipartite
the chromatic number \(x'(G)\) (minimum number of colors needed for proper edge coloring of graph) is equal to the degree \(\Delta + 1\) of the graph, (\(x'(G) = \Delta\))
The algorithm tries to assign the least possible color to every edge.
Does not always produce optimal coloring.
The returned rows are ordered in ascending order of the edge identifier.
Efficient graph coloring is an NPHard problem, and therefore:
In this implelentation the running time: \(O(E*V)\)
where \(E\) is the number of edges in the graph,
\(V\) is the number of vertices in the graph.
Signatures¶
(edge_id, color_id)
 Example:
Graph coloring of pgRouting Sample Data
SELECT * FROM pgr_edgeColoring(
'SELECT id, source, target, cost, reverse_cost FROM edges
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 as described below. 
Inner Queries¶
Edges SQL¶
Column 
Type 
Default 
Description 


ANYINTEGER 
Identifier of the edge. 


ANYINTEGER 
Identifier of the first end point vertex of the edge. 


ANYINTEGER 
Identifier of the second end point vertex of the edge. 


ANYNUMERICAL 
Weight of the edge ( 


ANYNUMERICAL 
1 
Weight of the edge (

Where:
 ANYINTEGER:
SMALLINT
,INTEGER
,BIGINT
 ANYNUMERICAL:
SMALLINT
,INTEGER
,BIGINT
,REAL
,FLOAT
Result Columns¶
Returns SET OF (edge_id, color_id)
Column 
Type 
Description 



Identifier of the edge. 


Identifier of the color of the edge.

See Also¶
The queries use the Sample Data network.
Indices and tables