Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage/graphs: Mark some doctests # optional - sage.groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Nov 20, 2021
1 parent 9123f4a commit 678ffc8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/sage/graphs/generators/families.py
Original file line number Diff line number Diff line change
Expand Up @@ -2790,8 +2790,8 @@ def HanoiTowerGraph(pegs, disks, labels=True, positions=True):
::
sage: H = graphs.HanoiTowerGraph(3,4,labels=False,positions=False)
sage: H.automorphism_group().is_isomorphic(SymmetricGroup(3))
sage: H = graphs.HanoiTowerGraph(3, 4, labels=False, positions=False)
sage: H.automorphism_group().is_isomorphic(SymmetricGroup(3)) # optional - sage.groups
True
sage: H.chromatic_number()
3
Expand Down
40 changes: 20 additions & 20 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -18704,33 +18704,33 @@ def _color_by_label(self, format='hex', as_function=False, default_color="black"
We consider the Cayley graph of the symmetric group, whose edges are
labelled by the numbers 1,2, and 3::

sage: G = SymmetricGroup(4).cayley_graph()
sage: set(G.edge_labels())
sage: G = SymmetricGroup(4).cayley_graph() # optional - sage.groups
sage: set(G.edge_labels()) # optional - sage.groups
{1, 2, 3}

We first request the coloring as a function::

sage: f = G._color_by_label(as_function=True)
sage: [f(1), f(2), f(3)]
sage: f = G._color_by_label(as_function=True) # optional - sage.groups
sage: [f(1), f(2), f(3)] # optional - sage.groups
['#0000ff', '#ff0000', '#00ff00']
sage: f = G._color_by_label({1: "blue", 2: "red", 3: "green"}, as_function=True)
sage: [f(1), f(2), f(3)]
sage: f = G._color_by_label({1: "blue", 2: "red", 3: "green"}, as_function=True) # optional - sage.groups
sage: [f(1), f(2), f(3)] # optional - sage.groups
['blue', 'red', 'green']
sage: f = G._color_by_label({1: "red"}, as_function=True)
sage: [f(1), f(2), f(3)]
sage: f = G._color_by_label({1: "red"}, as_function=True) # optional - sage.groups
sage: [f(1), f(2), f(3)] # optional - sage.groups
['red', 'black', 'black']
sage: f = G._color_by_label({1: "red"}, as_function=True, default_color='blue')
sage: [f(1), f(2), f(3)]
sage: f = G._color_by_label({1: "red"}, as_function=True, default_color='blue') # optional - sage.groups
sage: [f(1), f(2), f(3)] # optional - sage.groups
['red', 'blue', 'blue']

The default output is a dictionary assigning edges to colors::

sage: G._color_by_label()
sage: G._color_by_label() # optional - sage.groups
{'#0000ff': [((), (1,2), 1), ...],
'#00ff00': [((), (3,4), 3), ...],
'#ff0000': [((), (2,3), 2), ...]}

sage: G._color_by_label({1: "blue", 2: "red", 3: "green"})
sage: G._color_by_label({1: "blue", 2: "red", 3: "green"}) # optional - sage.groups
{'blue': [((), (1,2), 1), ...],
'green': [((), (3,4), 3), ...],
'red': [((), (2,3), 2), ...]}
Expand All @@ -18739,12 +18739,12 @@ def _color_by_label(self, format='hex', as_function=False, default_color="black"

We check what happens when several labels have the same color::

sage: result = G._color_by_label({1: "blue", 2: "blue", 3: "green"})
sage: sorted(result)
sage: result = G._color_by_label({1: "blue", 2: "blue", 3: "green"}) # optional - sage.groups
sage: sorted(result) # optional - sage.groups
['blue', 'green']
sage: len(result['blue'])
sage: len(result['blue']) # optional - sage.groups
48
sage: len(result['green'])
sage: len(result['green']) # optional - sage.groups
24
"""
if format is True:
Expand Down Expand Up @@ -21636,10 +21636,10 @@ def relabel(self, perm=None, inplace=True, return_map=False, check_input=True, c
Relabeling using a Sage permutation::

sage: G = graphs.PathGraph(3)
sage: from sage.groups.perm_gps.permgroup_named import SymmetricGroup
sage: S = SymmetricGroup(3)
sage: gamma = S('(1,2)')
sage: G.relabel(gamma, inplace=False).am()
sage: from sage.groups.perm_gps.permgroup_named import SymmetricGroup # optional - sage.groups
sage: S = SymmetricGroup(3) # optional - sage.groups
sage: gamma = S('(1,2)') # optional - sage.groups
sage: G.relabel(gamma, inplace=False).am() # optional - sage.groups
[0 0 1]
[0 0 1]
[1 1 0]
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@ class Graph(GenericGraph):
'out' is the label for the edge on 2 and 5. Labels can be used as
weights, if all the labels share some common parent.::
sage: a,b,c,d,e,f = sorted(SymmetricGroup(3))
sage: Graph({b:{d:'c',e:'p'}, c:{d:'p',e:'c'}})
sage: a, b, c, d, e, f = sorted(SymmetricGroup(3)) # optional - sage.groups
sage: Graph({b: {d: 'c', e: 'p'}, c: {d: 'p', e: 'c'}}) # optional - sage.groups
Graph on 4 vertices
#. A dictionary of lists::
Expand Down

0 comments on commit 678ffc8

Please sign in to comment.