Skip to content

Commit

Permalink
Add Misra-Gries edge coloring method (#902)
Browse files Browse the repository at this point in the history
* initial implementation

* cleanup

* cleanup

* changing to struct

* cleanup

* cleanup

* cleanup

* cleanup

* cleanup

* cleanup

* a few comments from code review

* switching to filter_map

* suggestion from code review

* minor

* performance improvements

* moving to rustworkx-core

* moving checking function under test

* improved tests

* docs example

* minor

* removing unused use from testing

* more unused

* python tests and wrapper function

* removing unused imports

* release notes and docs fixes

* merge fixes

* switching from EdgeId to EdgeRef

* aux functions to set/get edge color

* cleanup

* minor

* cleanup signature of fan to only store edge reference

* no need to explicitly specify type

* api docs

---------

Co-authored-by: Matthew Treinish <[email protected]>
  • Loading branch information
alexanderivrii and mtreinish authored Jan 10, 2024
1 parent 75dbca9 commit 6d82a11
Show file tree
Hide file tree
Showing 8 changed files with 533 additions and 10 deletions.
11 changes: 11 additions & 0 deletions docs/source/api/algorithm_functions/coloring.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.. _coloring:

Coloring
========

.. autosummary::
:toctree: ../../apiref

rustworkx.graph_greedy_color
rustworkx.graph_greedy_edge_color
rustworkx.graph_misra_gries_edge_color
1 change: 1 addition & 0 deletions docs/source/api/algorithm_functions/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Algorithm Functions
:maxdepth: 2

centrality
coloring
connectivity_and_cycles
dag_algorithms
graph_operations
Expand Down
2 changes: 0 additions & 2 deletions docs/source/api/algorithm_functions/other.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Other Algorithm Functions
rustworkx.adjacency_matrix
rustworkx.transitivity
rustworkx.core_number
rustworkx.graph_greedy_color
rustworkx.graph_greedy_edge_color
rustworkx.graph_line_graph
rustworkx.metric_closure
rustworkx.is_planar
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
features:
- |
Added a new function, :func:`~.graph_misra_gries_edge_color` to color edges
of a :class:`~.PyGraph` object using the Misra-Gries edge coloring algorithm.
The above algorithm is described in the paper paper: "A constructive proof of
Vizing's theorem" by Misra and Gries, 1992.
The coloring produces at most d + 1 colors where d is the maximum degree
of the graph.
.. jupyter-execute::
import rustworkx as rx
graph = rx.generators.cycle_graph(7)
edge_colors = rx.graph_misra_gries_edge_color(graph)
assert edge_colors == {0: 0, 1: 1, 2: 2, 3: 0, 4: 1, 5: 0, 6: 2}
Loading

0 comments on commit 6d82a11

Please sign in to comment.