---
title: coloring (latest version)
description: API reference for qiskit_addon_utils.coloring in the latest version of qiskit-addon-utils
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit-addon-utils/coloring
---

# coloring

`qiskit_addon_utils.coloring`

Utility methods for coloring.

### auto\_color\_edges

`auto_color_edges(edges)`

[GitHub](https://github.com/Qiskit/qiskit-addon-utils/tree/stable/0.4/qiskit_addon_utils/coloring/automatic_coloring.py#L22-L42)

Color the input edges of an undirected graph such that no two incident edges share a color.

**Parameters**

**edges** ([*Sequence*](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)*\[*[*tuple*](https://docs.python.org/3/library/stdtypes.html#tuple)*\[*[*int*](https://docs.python.org/3/library/functions.html#int)*,* [*int*](https://docs.python.org/3/library/functions.html#int)*]]*) – The edges describing an undirected graph.

**Returns**

A dictionary mapping each edge to an integer representation of a color.

**Return type**

[dict](https://docs.python.org/3/library/stdtypes.html#dict)\[[tuple](https://docs.python.org/3/library/stdtypes.html#tuple)\[[int](https://docs.python.org/3/library/functions.html#int), [int](https://docs.python.org/3/library/functions.html#int)], [int](https://docs.python.org/3/library/functions.html#int)]

### is\_valid\_edge\_coloring

`is_valid_edge_coloring(coloring)`

[GitHub](https://github.com/Qiskit/qiskit-addon-utils/tree/stable/0.4/qiskit_addon_utils/coloring/validation.py#L20-L38)

Check whether an edge coloring scheme is valid.

An edge coloring is valid if no two edges of the same color share a node.

**Parameters**

**coloring** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict)*\[*[*tuple*](https://docs.python.org/3/library/stdtypes.html#tuple)*\[*[*int*](https://docs.python.org/3/library/functions.html#int)*,* [*int*](https://docs.python.org/3/library/functions.html#int)*],* [*int*](https://docs.python.org/3/library/functions.html#int)*]*) – A mapping from edges to integer representations of colors.

**Returns**

A boolean indicating whether the input coloring is valid.

**Return type**

[bool](https://docs.python.org/3/library/functions.html#bool)
