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

Commit

Permalink
trac #15623: Rebase on updated #15622
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanncohen committed Jan 7, 2014
2 parents dcb8a0b + 6398780 commit 3531566
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/sage/combinat/posets/hasse_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ def dual(self):
sage: H.is_isomorphic( H.dual() )
False
"""
H = HasseDiagram(self.reverse())
H = self.reverse()
H.relabel(perm=range(H.num_verts()-1,-1,-1), inplace=True)
return H
return HasseDiagram(H)

def interval(self, x, y):
"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/graphs/base/static_sparse_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,12 @@ class StaticSparseBackend(CGraphBackend):
TEST::
sage: from sage.graphs.base.static_sparse_backend import StaticSparseCGraph
sage: g = StaticSparseCGraph(graphs.PetersenGraph())
sage: from sage.graphs.base.static_sparse_backend import StaticSparseBackend
sage: g = StaticSparseBackend(graphs.PetersenGraph())
sage: g.relabel([],True)
Traceback (most recent call last):
...
ValueError: Thou shalt not remove a vertex from an immutable graph
ValueError: Thou shalt not relabel an immutable graph
"""
raise ValueError("Thou shalt not relabel an immutable graph")
Expand Down
15 changes: 14 additions & 1 deletion src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -16557,12 +16557,22 @@ def relabel(self, perm=None, inplace=True, return_map=False, check_input = True,
sage: Graph(graphs.PetersenGraph(), immutable=True).relabel({})
Traceback (most recent call last):
...
ValueError: Thou shalt not relabel an immutable graph
ValueError: To relabel an immutable graph use inplace=False

A couple of lines to remove when hasse diagrams will not have a
``._immutable`` attribute by default::

sage: from sage.combinat.posets.hasse_diagram import HasseDiagram
sage: if getattr(HasseDiagram,'_immutable', "YES") == "YES":
....: print "two lines must be removed from this function"

"""
from sage.groups.perm_gps.permgroup_element import PermutationGroupElement

if not inplace:
G = self.copy(immutable=False)
if getattr(G, "_immutable", False): # can be removed when posets
G._immutable = False # have immutable backends
perm2 = G.relabel(perm,
return_map= return_map,
check_input = check_input,
Expand All @@ -16576,6 +16586,9 @@ def relabel(self, perm=None, inplace=True, return_map=False, check_input = True,
else:
return G

if getattr(self, "_immutable", False):
raise ValueError("To relabel an immutable graph use inplace=False")

# If perm is not a dictionary, we build one !

if perm is None:
Expand Down

0 comments on commit 3531566

Please sign in to comment.