Skip to content

Commit 31aded8

Browse files
author
Release Manager
committed
gh-41229: planar_graphs generator: support minimum_connectivity=4 plantri supports `-pc4` since version 5.0 released on October 2, 2016 but the [`planar_graphs()`](https://doc.sagemath.org/html/en/reference/g raphs/sage/graphs/graph_generators.html#sage.graphs.graph_generators.Gra phGenerators.planar_graphs) generator incorrectly claimed that `minimum_connectivity=4` was not supported. This pull request rectifies that. I also tried adding support for a more broad range of options to the `triangulations()` generator but I found it difficult to deal with the complex requirements between the various parameters. According to its README, plantri supports the following options, but not all combinations are allowed: ``` Planar triangulations connectivity 1, 2, 3, 4 or 5 minimum degree 3, 4 or 5 eulerian with connectivity 3 or 4 Planar quadrangulations arbitrary simple 3-connected minimum degree 3 and simple 3-connected, no non-facial 4-cycles arbitrary Planar simple graphs connectivity 1, 2, 3 or 4 minimum degree 1, 2, 3, 4 or 5 Planar simple bipartite graphs connectivity 1, 2 or 3 minimum degree 1, 2, or 3 Triangulations of a disk connectivity 2 or 3 minimum degree 2 or 3 Planar cubic graphs connectivity 1, 2, or 3 connectivity 1, 2, or 3 girth 3, 4 or 5 cyclic connectivity 3, 4 or 5 bipartite with cyclic connectivity 3 or 4 Planar quartic graphs 3-connected simple 4-edge-connected simple 4-edge-connected 3-connected, 6-cyclically-edge-connected arbitrary ``` URL: #41229 Reported by: Lennard Hofmann Reviewer(s):
2 parents 44533be + ed67c60 commit 31aded8

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/sage/graphs/graph_generators.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,16 +2033,15 @@ def planar_graphs(self, order, minimum_degree=None,
20332033
minimum connectivity is also equal to ``None``, then this is set to 1.
20342034
20352035
- ``minimum_connectivity`` -- (default: ``None``) a value `\geq 1`
2036-
and `\leq 3`, or ``None``. This specifies the minimum connectivity of the
2036+
and `\leq 4`, or ``None``. This specifies the minimum connectivity of the
20372037
generated graphs. If this is ``None`` and the minimum degree is
20382038
specified, then this is set to the minimum of the minimum degree
20392039
and 3. If the minimum degree is also equal to ``None``, then this
20402040
is set to 1.
20412041
20422042
- ``exact_connectivity`` -- (default: ``False``) if ``True`` only
20432043
graphs with exactly the specified connectivity will be generated.
2044-
This option cannot be used with ``minimum_connectivity=3``, or if
2045-
the minimum connectivity is not explicitly set.
2044+
This option requires ``minimum_connectivity`` to be set to 1 or 2.
20462045
20472046
- ``minimum_edges`` -- integer (default: ``None``); lower bound on the
20482047
number of edges
@@ -2150,6 +2149,15 @@ def planar_graphs(self, order, minimum_degree=None,
21502149
sage: dual_planar_sizes = [g.size() for g in dual_planar]
21512150
sage: planar_sizes == dual_planar_sizes
21522151
True
2152+
2153+
Specifying extremal values for minimum connectivity::
2154+
2155+
sage: # optional - plantri
2156+
sage: gen = graphs.planar_graphs(5, minimum_connectivity=1, exact_connectivity=True)
2157+
sage: all(G.vertex_connectivity() == 1 for G in gen)
2158+
True
2159+
sage: len(list(graphs.planar_graphs(8, minimum_connectivity=4)))
2160+
4
21532161
"""
21542162
if order < 0:
21552163
raise ValueError("number of vertices should be nonnegative")
@@ -2161,8 +2169,8 @@ def planar_graphs(self, order, minimum_degree=None,
21612169
if exact_connectivity and minimum_connectivity is None:
21622170
raise ValueError("Minimum connectivity must be specified to use the exact_connectivity option.")
21632171

2164-
if minimum_connectivity is not None and not (1 <= minimum_connectivity <= 3):
2165-
raise ValueError("Minimum connectivity should be a number between 1 and 3.")
2172+
if minimum_connectivity is not None and not (1 <= minimum_connectivity <= 4):
2173+
raise ValueError("Minimum connectivity should be a number between 1 and 4.")
21662174

21672175
# minimum degree should be None or a number between 1 and 5
21682176
if minimum_degree == 0:
@@ -2185,9 +2193,9 @@ def planar_graphs(self, order, minimum_degree=None,
21852193
minimum_degree > 0):
21862194
raise ValueError("Minimum connectivity can be at most the minimum degree.")
21872195

2188-
# exact connectivity is not implemented for minimum connectivity 3
2189-
if exact_connectivity and minimum_connectivity == 3:
2190-
raise NotImplementedError("Generation of planar graphs with connectivity exactly 3 is not implemented.")
2196+
# exact connectivity is not implemented for minimum connectivity 3
2197+
if exact_connectivity and minimum_connectivity >= 3:
2198+
raise NotImplementedError(f"Generation of planar graphs with connectivity exactly {minimum_connectivity} is not implemented.")
21912199

21922200
if only_bipartite and minimum_degree > 3:
21932201
raise NotImplementedError("Generation of bipartite planar graphs with minimum degree 4 or 5 is not implemented.")

0 commit comments

Comments
 (0)