Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #38832 about canonical_label in bipartite graphs #38842

Merged
merged 3 commits into from
Nov 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/sage/graphs/bipartite_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2633,11 +2633,26 @@ class by some canonization function `c`. If `G` and `H` are graphs,
sage: C.right
{4, 5, 6}

TESTS:

Check that :issue:`38832` is fixed::

sage: B = BipartiteGraph(matrix([[1, 1], [1, 1]]))
sage: B.canonical_label()
Bipartite graph on 4 vertices
sage: B.canonical_label(certificate=True)[0]
Bipartite graph on 4 vertices
sage: B.canonical_label(edge_labels=True)
Bipartite graph on 4 vertices
sage: B.allow_multiple_edges(True)
sage: B.add_edges(B.edges())
sage: B.canonical_label()
Bipartite multi-graph on 4 vertices

.. SEEALSO::

:meth:`~sage.graphs.generic_graph.GenericGraph.canonical_label()`
"""

if certificate:
C, cert = GenericGraph.canonical_label(self, partition=partition,
certificate=certificate,
Expand Down Expand Up @@ -2669,6 +2684,8 @@ class by some canonization function `c`. If `G` and `H` are graphs,
cert = {v: c[G_to[relabeling[v]]] for v in self}

else:
if partition is None:
partition = self.bipartition()
G_vertices = list(chain(*partition))
G_to = {u: i for i, u in enumerate(G_vertices)}
H = Graph(len(G_vertices))
Expand Down
Loading