-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add two_color and is_bipartite (#1002)
* Add two_color and is_bipartite This commit adds new functions to rustworkx, two_color() and is_bipartite(), which are used to compute a two coloring for a graph and then determine if a givn graph is bipartite. The two_color() function is added to rustworkx-core as the python is_bipartite() function just wraps it and converts the output to a bool if a two coloring is possible or not. This commit is based on top of #998 and will need to be rebased after that merges. * Remove special isolates handling * Expand test coverage
- Loading branch information
Showing
8 changed files
with
445 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
features: | ||
- | | ||
Added a new function ``two_color`` to the rustworkx-core ``rustworkx_core::coloring`` | ||
module. This function is used to compute a two coloring of a graph and can | ||
also be used to determine if a graph is bipartite as it returns ``None`` | ||
when a two coloring is not possible. | ||
- | | ||
Added a new function, :func:`~.two_color`, which is used to compute a | ||
two coloring for a graph. For example: | ||
.. jupyter-execute:: | ||
import rustworkx as rx | ||
from rustworkx.visualization import mpl_draw | ||
graph = rx.generators.heavy_square_graph(5) | ||
colors = rx.two_color(graph) | ||
mpl_draw(graph, node_color=list(colors.values())) | ||
- | | ||
Added a new function, :func:`~.is_bipartite` to determine whether a given | ||
graph object is bipartite or not. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.