sequential_vertex_coloring#
- graph_tool.topology.sequential_vertex_coloring(g, order=None, color=None)[source]#
Returns a vertex coloring of the graph.
- Parameters:
- g
Graph
Graph to be used.
- order
VertexPropertyMap
(optional, default:None
) Order with which the vertices will be colored.
- color
VertexPropertyMap
(optional, default:None
) Integer-valued vertex property map to store the colors.
- g
- Returns:
- color
VertexPropertyMap
Integer-valued vertex property map with the vertex colors.
- color
Notes
The time complexity is \(O(V(d+k))\), where \(V\) is the number of vertices, \(d\) is the maximum degree of the vertices in the graph, and \(k\) is the number of colors used.
References
[graph-coloring]Examples
>>> g = gt.lattice([10, 10]) >>> colors = gt.sequential_vertex_coloring(g) >>> print(colors.a) [0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 1 0 1 0]