Skip to content

Commit 18d5246

Browse files
Saatvik RaosaatvikraoIITGN
authored andcommitted
minor changes for code quality
1 parent 764c2af commit 18d5246

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/sage/graphs/graph.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4931,7 +4931,7 @@ def minor(self, H, solver=None, verbose=0, induced=False, *, integrality_toleran
49314931
:meth:`MixedIntegerLinearProgram.get_values`.
49324932
49334933
- ``induced`` -- boolean (default: ``False``); if ``True``, returns an
4934-
induced minor isomorphic to `H` if it exists, and ``ValueError`` otherwise.
4934+
induced minor isomorphic to `H` if it exists, and ``:class:`ValueError``` otherwise.
49354935
49364936
OUTPUT:
49374937
@@ -5004,20 +5004,15 @@ def minor(self, H, solver=None, verbose=0, induced=False, *, integrality_toleran
50045004
True
50055005
50065006
TESTS::
5007-
5007+
5008+
sage: # a graph `g` may have minor but no induced minor isomorphic to given graph `h`
50085009
sage: g = Graph([(0, 1), (0, 2), (1, 2), (2, 3), (3, 4), (3, 5), (4, 5), (6, 5)])
50095010
sage: h = Graph([(9, 10), (9, 11), (9, 12), (9, 13)])
5011+
sage: l = g.minor(h, induced=False)
50105012
sage: l = g.minor(h, induced=True)
50115013
Traceback (most recent call last):
50125014
...
50135015
ValueError: This graph has no induced minor isomorphic to H !
5014-
5015-
sage: # induced minor does not exist, but minor does
5016-
sage: g = Graph([(0, 1), (0, 2), (1, 2), (2, 3), (3, 4), (3, 5), (4, 5), (6, 5)])
5017-
sage: h = Graph([(9, 10), (9, 11), (9, 12), (9, 13)])
5018-
sage: l = g.minor(h, induced=False)
5019-
sage: print("minor exists")
5020-
minor exists
50215016
50225017
sage: g = Graph([(0, 1), (0, 2), (1, 2), (2, 3), (3, 4), (3, 5), (4, 5), (6, 5)])
50235018
sage: h = Graph([(7, 8), (8, 9), (9, 10), (10, 11)])
@@ -5106,7 +5101,10 @@ def minor(self, H, solver=None, verbose=0, induced=False, *, integrality_toleran
51065101
try:
51075102
p.solve(log=verbose)
51085103
except MIPSolverException:
5109-
raise ValueError("This graph has no minor isomorphic to H !")
5104+
if induced:
5105+
raise ValueError("This graph has no induced minor isomorphic to H !")
5106+
else:
5107+
raise ValueError("This graph has no minor isomorphic to H !")
51105108

51115109
rs = p.get_values(rs, convert=bool, tolerance=integrality_tolerance)
51125110

0 commit comments

Comments
 (0)