Skip to content

Commit 226c97a

Browse files
Saatvik RaoSaatvik Rao
authored andcommitted
minor changes in code style and doctests
1 parent c255d4b commit 226c97a

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

src/sage/graphs/graph.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4901,7 +4901,7 @@ def minor(self, H, solver=None, verbose=0, induced=False, *, integrality_toleran
49014901
been merged to create a new graph `G'`, this new graph contains `H` as a
49024902
subgraph.
49034903
4904-
When parameter ``induced`` is ``True``, this method returns an induced minor
4904+
When parameter ``induced`` is ``True``, this method returns an induced minor
49054905
isomorphic to `H`, if it exists.
49064906
49074907
We say that a graph `G` has an induced `H`-minor (or that it has a
@@ -4931,7 +4931,8 @@ 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 :class:`ValueError` otherwise.
4934+
induced minor isomorphic to `H` if it exists, and raises a
4935+
:class:`ValueError` otherwise.
49354936
49364937
OUTPUT:
49374938
@@ -4991,21 +4992,24 @@ def minor(self, H, solver=None, verbose=0, induced=False, *, integrality_toleran
49914992
...
49924993
ValueError: This graph has no minor isomorphic to H !
49934994
4994-
Trying to find an induced minor for a graph with a C6 cycle::
4995+
Trying to find an induced minor isomorphic to `C_5` in a graph
4996+
containing an induced `C_6`::
49954997
4996-
sage: g = graphs.CycleGraph(6) # Create a graph with 6 vertices forming a C6 cycle
4997-
sage: for i in random.randint(10, 30):
4998-
....: g.add_edge(random.randint(0, 5), i)
4999-
sage: h = graphs.CycleGraph(5) # Create a graph with 5 vertices forming a C5 cycle
5000-
sage: L = g.minor(h, induced=True)
5001-
sage: gg = g.subgraph(flatten(L.values(), max_level = 1))
5002-
sage: _ = [gg.merge_vertices(l) for l in L.values() if len(l)>1]
4998+
sage: g = graphs.CycleGraph(6)
4999+
sage: for i in range(randint(10, 30)):
5000+
....: g.add_edge(randint(0, 5), g.add_vertex())
5001+
sage: h = graphs.CycleGraph(5)
5002+
sage: L = g.minor(h, induced=True)
5003+
sage: gg = g.subgraph(flatten(L.values(), max_level=1))
5004+
sage: _ = [gg.merge_vertices(l) for l in L.values() if len(l) > 1]
50035005
sage: gg.is_isomorphic(h)
50045006
True
50055007
50065008
TESTS::
50075009
5008-
sage: # a graph `g` may have minor but no induced minor isomorphic to given graph `h`
5010+
A graph `g` may have a minor isomorphic to a given graph `h` but no
5011+
induced minor isomorphic to `h`::
5012+
50095013
sage: g = Graph([(0, 1), (0, 2), (1, 2), (2, 3), (3, 4), (3, 5), (4, 5), (6, 5)])
50105014
sage: h = Graph([(9, 10), (9, 11), (9, 12), (9, 13)])
50115015
sage: l = g.minor(h, induced=False)
@@ -5014,11 +5018,14 @@ def minor(self, H, solver=None, verbose=0, induced=False, *, integrality_toleran
50145018
...
50155019
ValueError: This graph has no induced minor isomorphic to H !
50165020
5021+
Checking that the returned induced minor is isomorphic to the given
5022+
graph::
5023+
50175024
sage: g = Graph([(0, 1), (0, 2), (1, 2), (2, 3), (3, 4), (3, 5), (4, 5), (6, 5)])
50185025
sage: h = Graph([(7, 8), (8, 9), (9, 10), (10, 11)])
50195026
sage: L = g.minor(h, induced=True)
5020-
sage: gg = g.subgraph(flatten(L.values(), max_level = 1))
5021-
sage: _ = [gg.merge_vertices(l) for l in L.values() if len(l)>1]
5027+
sage: gg = g.subgraph(flatten(L.values(), max_level=1))
5028+
sage: _ = [gg.merge_vertices(l) for l in L.values() if len(l) > 1]
50225029
sage: gg.is_isomorphic(h)
50235030
True
50245031
"""

0 commit comments

Comments
 (0)