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

Commit

Permalink
trac #27183: other doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoudert committed Jan 31, 2019
1 parent 0cb4942 commit df37258
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/sage/graphs/generic_graph.py
Expand Up @@ -17087,9 +17087,10 @@ def lex_BFS(self, reverse=False, tree=False, initial_vertex=None):
For a Chordal Graph, a reversed Lex BFS is a Perfect Elimination Order::

sage: g = graphs.PathGraph(3).lexicographic_product(graphs.CompleteGraph(2))
sage: g.lex_BFS(reverse=True)
sage: g.lex_BFS(reverse=True) # py2
[(2, 0), (2, 1), (1, 1), (1, 0), (0, 0), (0, 1)]

sage: g.lex_BFS(reverse=True) # py3
[(2, 1), (2, 0), (1, 1), (1, 0), (0, 1), (0, 0)]

And the vertices at the end of the tree of discovery are, for chordal
graphs, simplicial vertices (their neighborhood is a complete graph)::
Expand Down Expand Up @@ -18205,8 +18206,10 @@ def _color_by_label(self, format='hex', as_function=False, default_color="black"
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(1), f(2), f(3)] # py2
['#ff0000', '#0000ff', '#00ff00']
sage: [f(1), f(2), f(3)] # py3
['#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)]
['blue', 'red', 'green']
Expand All @@ -18219,15 +18222,23 @@ def _color_by_label(self, format='hex', as_function=False, default_color="black"

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

sage: G._color_by_label()
sage: G._color_by_label() # py2
{'#0000ff': [((1,3,2,4), (1,2,4), 2), ...],
'#00ff00': [((1,3,2,4), (1,4)(2,3), 3), ...],
'#ff0000': [((1,3,2,4), (1,3)(2,4), 1), ...]}
sage: G._color_by_label() # py3
{'#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"}) # py2
{'blue': [((1,3,2,4), (1,3)(2,4), 1), ...],
'green': [((1,3,2,4), (1,4)(2,3), 3), ...],
'red': [((1,3,2,4), (1,2,4), 2), ...]}
sage: G._color_by_label({1: "blue", 2: "red", 3: "green"}) # py3
{'blue': [((), (1,2), 1), ...],
'green': [((), (3,4), 3), ...],
'red': [((), (2,3), 2), ...]}

TESTS:

Expand Down Expand Up @@ -18577,10 +18588,15 @@ def layout_extend_randomly(self, pos, dim=2):
EXAMPLES::

sage: H = digraphs.ButterflyGraph(1)
sage: H.layout_extend_randomly({('0', 0): (0, 0), ('1', 1): (1, 1)})
sage: H.layout_extend_randomly({('0', 0): (0, 0), ('1', 1): (1, 1)}) # py2
{('0', 0): (0, 0),
('0', 1): [0.0446..., 0.332...],
('1', 0): [0.111..., 0.514...],
('1', 0): [0.1114..., 0.514...],
('1', 1): (1, 1)}
sage: H.layout_extend_randomly({('0', 0): (0, 0), ('1', 1): (1, 1)}) # py3
{('0', 0): (0, 0),
('0', 1): [0.1114..., 0.514...],
('1', 0): [0.0446..., 0.332...],
('1', 1): (1, 1)}
"""
assert dim == 2 # 3d not yet implemented
Expand Down

0 comments on commit df37258

Please sign in to comment.