diff --git a/src/sage/graphs/bipartite_graph.py b/src/sage/graphs/bipartite_graph.py index 45e4c67747d..e21ec47e9cf 100644 --- a/src/sage/graphs/bipartite_graph.py +++ b/src/sage/graphs/bipartite_graph.py @@ -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, @@ -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))