sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.41k stars 474 forks source link

`.canonical_label()` errors on bipartite graphs when `partition=` is not specified #38832

Open maxale opened 4 days ago

maxale commented 4 days ago

Steps To Reproduce

sage: G = BipartiteGraph( matrix([[1,1],[1,1]]) )
sage: G.canonical_label()
[...]
TypeError: itertools.chain() argument after * must be an iterable, not NoneType

Expected Behavior

Should work.

Actual Behavior

TypeError

Additional Information

Specifying partition= eliminates the issue:

sage: G.canonical_label(partition=G.bipartition())
Bipartite graph on 4 vertices

Perhaps, G.bipartition() should be the default value for partition= in the case of bipartite graphs.

Environment

Checklist

dcoudert commented 1 day ago

good catch. I pushed a possible fix in #38842.