Ticket #13747: trac_13747.patch
File trac_13747.patch, 33.0 KB (added by , 8 years ago) |
---|
-
sage/combinat/posets/elements.py
# HG changeset patch # User Nathann Cohen <nathann.cohen@gmail.com> # Date 1353725066 -3600 # Node ID 5fbca18f0f90bcefcf1d37f87d6069855b63cc3c # Parent b5bbe67684871630c211855b34ae0112d598f799 Change default behaviour of Poset to facade = True diff --git a/sage/combinat/posets/elements.py b/sage/combinat/posets/elements.py
a b 38 38 TESTS:: 39 39 40 40 sage: from sage.combinat.posets.elements import PosetElement 41 sage: P = Poset([[1,2],[4],[3],[4],[]] )41 sage: P = Poset([[1,2],[4],[3],[4],[]], facade = False) 42 42 sage: e = P(0) 43 43 sage: e.parent() is P 44 44 True … … 55 55 """ 56 56 TESTS:: 57 57 58 sage: Poset([[1,2],[4],[3],[4],[]] )(0)._repr_()58 sage: Poset([[1,2],[4],[3],[4],[]], facade = False)(0)._repr_() 59 59 '0' 60 60 """ 61 61 return "%s" %str(self.element) … … 68 68 69 69 sage: m = matrix(2,[1,2,3,4]) 70 70 sage: m.set_immutable() 71 sage: P = Poset(([m],[]) )71 sage: P = Poset(([m],[]), facade = False) 72 72 sage: [e] = P 73 73 sage: type(e) 74 74 <class 'sage.combinat.posets.elements.FinitePoset_with_category.element_class'> … … 85 85 """ 86 86 TESTS:: 87 87 88 sage: P = Poset([["a","b"],["d"],["c"],["d"],[]] )89 sage: Q = Poset([["a","b"],["d"],["c"],[],[]] )88 sage: P = Poset([["a","b"],["d"],["c"],["d"],[]], facade = False) 89 sage: Q = Poset([["a","b"],["d"],["c"],[],[]], facade = False) 90 90 sage: P(0).__eq__(P(4)) 91 91 False 92 92 sage: from sage.combinat.posets.elements import PosetElement … … 142 142 """ 143 143 TESTS:: 144 144 145 sage: P = Poset([[1,2],[4],[3],[4],[]] )145 sage: P = Poset([[1,2],[4],[3],[4],[]], facade = False) 146 146 sage: P(0)._cmp(P(4)) 147 147 -1 148 148 sage: P(4)._cmp(P(0)) … … 175 175 176 176 TESTS:: 177 177 178 sage: P = Poset([[1,2],[4],[3],[4],[]] )178 sage: P = Poset([[1,2],[4],[3],[4],[]], facade = False) 179 179 sage: P(0).__cmp__(P(4)) 180 180 -1 181 181 sage: P(4).__cmp__(P(0)) … … 211 211 :: 212 212 213 213 sage: dag = DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}) 214 sage: P = Poset(dag )214 sage: P = Poset(dag, facade = False) 215 215 sage: P(0) < P(1) 216 216 False 217 217 sage: P(4) < P(1) … … 228 228 :: 229 229 230 230 sage: dag = DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}) 231 sage: P = Poset(dag )231 sage: P = Poset(dag, facade = False) 232 232 sage: P(1) <= P(0) 233 233 False 234 234 sage: P(0) <= P(1) -
sage/combinat/posets/lattices.py
diff --git a/sage/combinat/posets/lattices.py b/sage/combinat/posets/lattices.py
a b 329 329 P = Poset(data, *args, **options) 330 330 if not P.is_lattice(): 331 331 raise ValueError, "Not a lattice." 332 return FiniteLatticePoset(P, category = FiniteLatticePosets()) 332 333 return FiniteLatticePoset(P, category = FiniteLatticePosets(), facade = P._is_facade) 333 334 334 335 class FiniteLatticePoset(FiniteMeetSemilattice, FiniteJoinSemilattice): 335 336 """ -
sage/combinat/posets/linear_extensions.py
diff --git a/sage/combinat/posets/linear_extensions.py b/sage/combinat/posets/linear_extensions.py
a b 50 50 51 51 EXAMPLES:: 52 52 53 sage: P = Poset(([1,2,3,4], [[1,3],[1,4],[2,3]]), linear_extension=True )53 sage: P = Poset(([1,2,3,4], [[1,3],[1,4],[2,3]]), linear_extension=True, facade = False) 54 54 sage: p = P.linear_extension([1,4,2,3]); p 55 55 [1, 4, 2, 3] 56 56 sage: p.parent() … … 183 183 184 184 EXAMPLES:: 185 185 186 sage: P = Poset(([1,2,3,4], [[1,2],[1,3],[3,4]]) )186 sage: P = Poset(([1,2,3,4], [[1,2],[1,3],[3,4]]), facade = False) 187 187 sage: p = P.linear_extension([1,3,4,2]) 188 188 sage: Q = p.to_poset(); Q 189 189 Finite poset containing 4 elements -
sage/combinat/posets/posets.py
diff --git a/sage/combinat/posets/posets.py b/sage/combinat/posets/posets.py
a b 2 2 r""" 3 3 Posets 4 4 5 This module implements finite partialy ordered sets. The main 6 constructor is :meth:`Poset`. 5 This module implements finite partialy ordered sets. It defines : 6 7 .. csv-table:: 8 :class: contentstable 9 :widths: 30, 70 10 :delim: | 11 12 :class:`FinitePoset` | A class for finite posets 13 :class:`FinitePosets_n` | A class for finite posets up to isomorphism (i.e. unlabeled posets) 14 :meth:`Poset` | Construct a finite poset from various forms of input data. 15 :meth:`is_poset` | Tests whether a directed graph is acyclic and transitively reduced. 16 17 **List of Poset methods** 18 19 .. csv-table:: 20 :class: contentstable 21 :widths: 30, 70 22 :delim: | 23 24 :meth:`~FinitePoset.antichains_iterator` | Returns an iterator over the antichains of the poset. 25 :meth:`~FinitePoset.antichains` | Returns the antichains of the poset. 26 :meth:`~FinitePoset.bottom` | Returns the bottom element of the poset, if it exists. 27 :meth:`~FinitePoset.cardinality` | Returns the number of elements in the poset. 28 :meth:`~FinitePoset.chains` | Returns all the chains of ``self`` 29 :meth:`~FinitePoset.closed_interval` | Returns a list of the elements `z` such that `x \le z \le y`. 30 :meth:`~FinitePoset.compare_elements` | Compare `x` and `y` in the poset. 31 :meth:`~FinitePoset.cover_relations_iterator` | Returns an iterator for the cover relations of the poset. 32 :meth:`~FinitePoset.cover_relations` | Returns the list of pairs [u,v] which are cover relations 33 :meth:`~FinitePoset.covers` | Returns True if y covers x and False otherwise. 34 :meth:`~FinitePoset.coxeter_transformation` | Returns the matrix of the Auslander-Reiten translation acting on the Grothendieck group of the derived category of modules 35 :meth:`~FinitePoset.dual` | Returns the dual poset of the given poset. 36 :meth:`~FinitePoset.evacuation` | Computes evacuation on the linear extension associated to the poset ``self``. 37 :meth:`~FinitePoset.graphviz_string` | Returns a representation in the DOT language, ready to render in graphviz. 38 :meth:`~FinitePoset.has_bottom` | Returns True if the poset has a unique minimal element. 39 :meth:`~FinitePoset.hasse_diagram` | Returns the Hasse diagram of ``self`` as a Sage :class:`DiGraph`. 40 :meth:`~FinitePoset.has_top` | Returns True if the poset contains a unique maximal element, and False otherwise. 41 :meth:`~FinitePoset.interval` | Returns a list of the elements `z` such that `x \le z \le y`. 42 :meth:`~FinitePoset.is_bounded` | Returns True if the poset contains a unique maximal element and a unique minimal element, and False otherwise. 43 :meth:`~FinitePoset.is_chain` | Returns True if the poset is totally ordered, and False otherwise. 44 :meth:`~FinitePoset.is_gequal` | Returns ``True`` if `x` is greater than or equal to `y` in the poset, and ``False`` otherwise. 45 :meth:`~FinitePoset.is_graded` | Returns whether this poset is graded. 46 :meth:`~FinitePoset.is_greater_than` | Returns ``True`` if `x` is greater than but not equal to `y` in the poset, and ``False`` otherwise. 47 :meth:`~FinitePoset.is_isomorphic` | Returns True if both posets are isomorphic. 48 :meth:`~FinitePoset.is_join_semilattice` | Returns True is the poset has a join operation, and False otherwise. 49 :meth:`~FinitePoset.is_lequal` | Returns ``True`` if `x` is less than or equal to `y` in the poset, and ``False`` otherwise. 50 :meth:`~FinitePoset.is_less_than` | Returns ``True`` if `x` is less than but not equal to `y` in the poset, and ``False`` otherwise. 51 :meth:`~FinitePoset.is_linear_extension` | Returns whether ``l`` is a linear extension of ``self`` 52 :meth:`~FinitePoset.is_meet_semilattice` | Returns True if self has a meet operation, and False otherwise. 53 :meth:`~FinitePoset.join_matrix` | Returns a matrix whose ``(i,j)`` entry is ``k``, where ``self.linear_extension()[k]`` is the join (least upper bound) of ``self.linear_extension()[i]`` and ``self.linear_extension()[j]``. 54 :meth:`~FinitePoset.is_ranked` | Returns whether this poset is ranked. 55 :meth:`~FinitePoset.is_slender` | Returns whether the poset ``self`` is slender or not. 56 :meth:`~FinitePoset.lequal_matrix` | Computes the matrix whose ``(i,j)`` entry is 1 if ``self.linear_extension()[i] < self.linear_extension()[j]`` and 0 otherwise 57 :meth:`~FinitePoset.level_sets` | Returns a list l such that l[i+1] is the set of minimal elements of the poset obtained by removing the elements in l[0], l[1], ..., l[i]. 58 :meth:`~FinitePoset.linear_extension` | Returns a linear extension of this poset. 59 :meth:`~FinitePoset.linear_extensions` | Returns the enumerated set of all the linear extensions of this poset 60 :meth:`~FinitePoset.list` | List the elements of the poset. This just returns the result of :meth:`linear_extension`. 61 :meth:`~FinitePoset.lower_covers_iterator` | Returns an iterator for the lower covers of the element y. An lower cover of y is an element x such that y x is a cover relation. 62 :meth:`~FinitePoset.lower_covers` | Returns a list of lower covers of the element y. An lower cover of y is an element x such that y x is a cover relation. 63 :meth:`~FinitePoset.maximal_chains` | Returns all maximal chains of this poset. Each chain is listed in increasing order. 64 :meth:`~FinitePoset.maximal_elements` | Returns a list of the maximal elements of the poset. 65 :meth:`~FinitePoset.meet_matrix` | Returns a matrix whose ``(i,j)`` entry is ``k``, where ``self.linear_extension()[k]`` is the meet (greatest lower bound) of ``self.linear_extension()[i]`` and ``self.linear_extension()[j]``. 66 :meth:`~FinitePoset.minimal_elements` | Returns a list of the minimal elements of the poset. 67 :meth:`~FinitePoset.mobius_function_matrix` | Returns a matrix whose ``(i,j)`` entry is the value of the Mobius function evaluated at ``self.linear_extension()[i]`` and ``self.linear_extension()[j]``. 68 :meth:`~FinitePoset.mobius_function` | Returns the value of the Mobius function of the poset on the elements x and y. 69 :meth:`~FinitePoset.open_interval` | Returns a list of the elements `z` such that `x < z < y`. The order is that induced by the ordering in 70 :meth:`~FinitePoset.order_complex` | Returns the order complex associated to this poset. 71 :meth:`~FinitePoset.order_filter` | Returns the order filter generated by a list of elements. 72 :meth:`~FinitePoset.order_ideal` | Returns the order ideal generated by a list of elements. 73 :meth:`~FinitePoset.plot` | Returns a Graphic object corresponding the Hasse diagram of the poset. 74 :meth:`~FinitePoset.product` | Returns the cartesian product of ``self`` and ``other``. 75 :meth:`~FinitePoset.promotion` | Computes the (extended) promotion on the linear extension of the poset ``self`` 76 :meth:`~FinitePoset.random_subposet` | Returns a random subposet that contains each element with probability p. 77 :meth:`~FinitePoset.rank_function` | Returns a rank function of the poset, if it exists. 78 :meth:`~FinitePoset.rank` | Returns the rank of an element, or the rank of the poset if element is None. 79 :meth:`~FinitePoset.relabel` | Returns a copy of this poset with its elements relabelled 80 :meth:`~FinitePoset.relations_iterator` | Returns an iterator for all the relations of the poset. 81 :meth:`~FinitePoset.relations` | Returns a list of all relations of the poset. 82 :meth:`~FinitePoset.show` | Shows the Graphics object corresponding the Hasse diagram of the poset. 83 :meth:`~FinitePoset.subposet` | Returns the poset containing elements with partial order induced by that of self. 84 :meth:`~FinitePoset.top` | Returns the top element of the poset, if it exists. 85 :meth:`~FinitePoset.unwrap` | Unwraps an element of this poset 86 :meth:`~FinitePoset.upper_covers_iterator` | Returns an iterator for the upper covers of the element y. An upper cover of y is an element x such that y x is a cover relation. 87 :meth:`~FinitePoset.upper_covers` | Returns a list of upper covers of the element y. An upper cover of y is an element x such that y x is a cover relation. 88 :meth:`~FinitePoset.with_linear_extension` | Returns a copy of ``self`` with a different default linear extension 89 90 Classes and functions 91 --------------------- 7 92 """ 8 93 #***************************************************************************** 9 94 # Copyright (C) 2008 Peter Jipsen <jipsen@chapman.edu>, … … 91 176 use the provided list of elements as default linear extension 92 177 for the poset; otherwise a linear extension is computed. 93 178 94 - ``facade`` -- a boolean (default: False); whether the Poset's 95 elements should be wrapped to make them aware of the Poset they 96 belong to. See below for details. 179 - ``facade`` -- a boolean or ``None`` (default); whether the 180 :meth:`Poset`'s elements should be wrapped to make them aware of the Poset 181 they belong to. 182 183 * If ``facade = True``, the :meth:`Poset`'s elements are exactly those 184 given as input. 185 186 * If ``facade = False``, the :meth:`Poset`'s elements will become 187 :class:`~sage.combinat.posets.posets.PosetElement` objects. 188 189 * If ``facade = None`` (default) the expected behaviour is the behaviour 190 of ``facade = True``, unless the opposite can be deduced from the 191 context (i.e. for instance if a :meth:`Poset` is built from another 192 :meth:`Poset`, itself built with ``facade = False``) 97 193 98 194 OUTPUT: 99 195 100 ``FinitePoset`` -- an instance of the ``FinitePoset`` class.196 ``FinitePoset`` -- an instance of the :class:`FinitePoset`` class. 101 197 102 198 If ``category`` is specified, then the poset is created in this 103 199 category instead of :class:`FinitePosets`. … … 110 206 111 207 sage: elms = [1,2,3,4,5,6,7] 112 208 sage: rels = [[1,2],[3,4],[4,5],[2,5]] 113 sage: Poset((elms, rels), cover_relations = True )209 sage: Poset((elms, rels), cover_relations = True, facade = False) 114 210 Finite poset containing 7 elements 115 211 116 212 Elements and non-cover relations:: … … 157 253 A list of upper covers and a dictionary of labels:: 158 254 159 255 sage: elm_labs = {0:"a",1:"b",2:"c",3:"d",4:"e"} 160 sage: P = Poset([[1,2],[4],[3],[4],[]],elm_labs )256 sage: P = Poset([[1,2],[4],[3],[4],[]],elm_labs, facade = False) 161 257 sage: P.list() 162 258 [a, b, c, d, e] 163 259 … … 176 272 Finite poset containing 6 elements 177 273 178 274 Any directed acyclic graph without loops or multiple edges, as long 179 as cover_relations=False::275 as ``cover_relations=False``:: 180 276 181 277 sage: dig = DiGraph({0:[2,3], 1:[3,4,5], 2:[5], 3:[5], 4:[5]}) 182 278 sage: dig.allows_multiple_edges() … … 222 318 223 319 .. rubric:: Facade posets 224 320 225 By default, the elements of a poset are wrapped so as to make them226 aware that they belong to that poset::227 228 sage: P = Poset(DiGraph({'d':['c','b'],'c':['a'],'b':['a']}) )321 When ``facade = False``, the elements of a poset are wrapped so as to make 322 them aware that they belong to that poset:: 323 324 sage: P = Poset(DiGraph({'d':['c','b'],'c':['a'],'b':['a']}), facade = False) 229 325 sage: d,c,b,a = list(P) 230 326 sage: a.parent() is P 231 327 True … … 251 347 sage: a.element + b.element 252 348 'ac' 253 349 254 Alternatively, one can construct instead facade posets:: 255 256 sage: P = Poset(DiGraph({'d':['c','b'],'c':['a'],'b':['a']}), 257 ... facade = True) 350 By default, facade posets are constructed instead:: 351 352 sage: P = Poset(DiGraph({'d':['c','b'],'c':['a'],'b':['a']})) 258 353 259 354 In this example, the elements of the poset remain plain strings:: 260 355 … … 299 394 vertices of a poset to :class:`Integer`'s if they are 300 395 :class:`int`'s:: 301 396 302 sage: P = Poset((divisors(15), attrcall("divides")) )397 sage: P = Poset((divisors(15), attrcall("divides")), facade = False) 303 398 sage: type(P.an_element().element) 304 399 <type 'sage.rings.integer.Integer'> 305 400 … … 343 438 :class:`UniqueRepresentation`. It is otherwise ignored by the 344 439 poset constructor. 345 440 346 347 441 TESTS:: 348 442 349 443 sage: P = Poset([[1,2],[3],[3]]) … … 466 560 467 561 - ``category`` -- :class:`FinitePosets`, or a subcategory thereof. 468 562 469 - ``facade`` -- a boolean or ``None`` (the default). 563 - ``facade`` -- a boolean or ``None`` (default); whether the 564 :class:`~sage.combinat.posets.posets.FinitePoset`'s elements should be 565 wrapped to make them aware of the Poset they belong to. 566 567 * If ``facade = True``, the 568 :class:`~sage.combinat.posets.posets.FinitePoset`'s elements are exactly 569 those given as input. 570 571 * If ``facade = False``, the 572 :class:`~sage.combinat.posets.posets.FinitePoset`'s elements will become 573 :class:`~sage.combinat.posets.posets.PosetElement` objects. 574 575 * If ``facade = None`` (default) the expected behaviour is the behaviour 576 of ``facade = True``, unless the opposite can be deduced from the 577 context (i.e. for instance if a 578 :class:`~sage.combinat.posets.posets.FinitePoset` is built from another 579 :class:`~sage.combinat.posets.posets.FinitePoset`, itself built with 580 ``facade = False``) 470 581 471 582 - ``key`` -- any hashable value (default: ``None``). 472 583 … … 474 585 475 586 sage: uc = [[2,3], [], [1], [1], [1], [3,4]] 476 587 sage: from sage.combinat.posets.posets import FinitePoset 477 sage: P = FinitePoset(DiGraph(dict([[i,uc[i]] for i in range(len(uc))])) ); P588 sage: P = FinitePoset(DiGraph(dict([[i,uc[i]] for i in range(len(uc))])), facade = False); P 478 589 Finite poset containing 6 elements 479 590 sage: P.cover_relations() 480 591 [[0, 2], [0, 3], [2, 1], [3, 1], [4, 1], [5, 3], [5, 4]] … … 484 595 sage: P.__class__ 485 596 <class 'sage.combinat.posets.posets.FinitePoset_with_category'> 486 597 487 sage: Q = sage.combinat.posets.posets.FinitePoset(P ); Q598 sage: Q = sage.combinat.posets.posets.FinitePoset(P, facade = False); Q 488 599 Finite poset containing 6 elements 489 600 490 601 sage: Q is P … … 492 603 493 604 We keep the same underlying hasse diagram, but change the elements:: 494 605 495 sage: Q = sage.combinat.posets.posets.FinitePoset(P, elements=[1,2,3,4,5,6] ); Q606 sage: Q = sage.combinat.posets.posets.FinitePoset(P, elements=[1,2,3,4,5,6], facade = False); Q 496 607 Finite poset containing 6 elements 497 608 sage: Q.cover_relations() 498 609 [[1, 3], [1, 4], [3, 2], [4, 2], [5, 2], [6, 4], [6, 5]] 499 610 500 611 We test the facade argument:: 501 612 502 sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}) )613 sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}), facade = False) 503 614 sage: P.category() 504 615 Category of finite posets 505 616 sage: parent(P[0]) is P … … 611 722 if elements is None: 612 723 elements = hasse_diagram.vertices() 613 724 if facade is None: 614 facade = False725 facade = True 615 726 elements = tuple(elements) 616 727 category = Category.join([FinitePosets().or_subcategory(category), FiniteEnumeratedSets()]) 617 728 return super(FinitePoset, cls).__classcall__(cls, hasse_diagram = hasse_diagram, elements = elements, … … 621 732 """ 622 733 EXAMPLES:: 623 734 624 sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}) )735 sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}), facade = False) 625 736 sage: type(P) 626 737 <class 'sage.combinat.posets.posets.FinitePoset_with_category'> 627 738 … … 680 791 681 792 EXAMPLES:: 682 793 683 sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}) )794 sage: P = Poset(DiGraph({'a':['b'],'b':['c'],'c':['d']}), facade = False) 684 795 sage: L = P._list; L 685 796 (a, b, c, d) 686 797 sage: type(L[0]) … … 724 835 725 836 TESTS:: 726 837 727 sage: P = Poset((divisors(15), attrcall("divides")) )838 sage: P = Poset((divisors(15), attrcall("divides")), facade = False) 728 839 729 840 Testing for wrapped elements:: 730 841 … … 758 869 759 870 EXAMPLES:: 760 871 761 sage: P = Poset((divisors(15), attrcall("divides")) )872 sage: P = Poset((divisors(15), attrcall("divides")), facade = False) 762 873 sage: x = P._vertex_to_element(2) 763 874 sage: x 764 875 5 … … 784 895 785 896 EXAMPLES:: 786 897 787 sage: P = Poset((divisors(15), attrcall("divides")) )898 sage: P = Poset((divisors(15), attrcall("divides")), facade = False) 788 899 sage: x = P.an_element(); x 789 900 1 790 901 sage: x.parent() … … 854 965 EXAMPLES:: 855 966 856 967 sage: from sage.combinat.posets.posets import FinitePoset 857 sage: P = FinitePoset(DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}) )968 sage: P = FinitePoset(DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}), facade = False) 858 969 sage: P(5) 859 970 5 860 sage: Q = FinitePoset(DiGraph({5:[2,3], 1:[3,4], 2:[0], 3:[0], 4:[0]}) )971 sage: Q = FinitePoset(DiGraph({5:[2,3], 1:[3,4], 2:[0], 3:[0], 4:[0]}), facade = False) 861 972 sage: Q(5) 862 973 5 863 974 … … 869 980 True 870 981 sage: Q(5) == Q(-1) 871 982 True 872 sage: R = FinitePoset(DiGraph({'a':['b','c'], 'b':['d'], 'c':['d'], 'd':[]}) )983 sage: R = FinitePoset(DiGraph({'a':['b','c'], 'b':['d'], 'c':['d'], 'd':[]}), facade = False) 873 984 sage: R(0) 874 985 a 875 986 sage: R('a') == R(0) … … 886 997 887 998 TESTS:: 888 999 889 sage: P = Poset(DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}) )1000 sage: P = Poset(DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]}), facade = False) 890 1001 sage: all(P(x) is x for x in P) 891 1002 True 892 1003 sage: P = Poset((divisors(15), attrcall("divides")), facade = True) … … 941 1052 942 1053 EXAMPLES:: 943 1054 944 sage: Q = Poset({5:[2,3], 1:[3,4], 2:[0], 3:[0], 4:[0]} )1055 sage: Q = Poset({5:[2,3], 1:[3,4], 2:[0], 3:[0], 4:[0]}, facade = False) 945 1056 sage: Q.hasse_diagram() 946 1057 Digraph on 6 vertices 947 1058 948 sage: P = Poset({'a':['b'],'b':['d'],'c':['d'],'d':['f'],'e':['f'],'f':[]} )1059 sage: P = Poset({'a':['b'],'b':['d'],'c':['d'],'d':['f'],'e':['f'],'f':[]}, facade = False) 949 1060 sage: H = P.hasse_diagram() 950 1061 sage: P.cover_relations() 951 1062 [[e, f], [c, d], [a, b], [b, d], [d, f]] 952 1063 sage: H.edges() 953 1064 [(a, b, None), (c, d, None), (b, d, None), (e, f, None), (d, f, None)] 954 1065 955 sage: P = Poset((divisors(15), attrcall("divides")) )1066 sage: P = Poset((divisors(15), attrcall("divides")), facade = False) 956 1067 sage: H = P.hasse_diagram() 957 1068 sage: H.vertices() 958 1069 [1, 5, 3, 15] … … 1088 1199 1089 1200 INPUT: 1090 1201 1091 - ``facade`` -- a boolean (default: False);1202 - ``facade`` -- a boolean (default: ``False``); 1092 1203 whether to return the linear extensions as plain lists 1093 1204 1205 .. warning:: 1206 1207 The ``facade`` option is not yet fully functional:: 1208 1209 sage: P = Poset((divisors(12), attrcall("divides")), linear_extension=True) 1210 sage: L = P.linear_extensions(facade=True); L 1211 The set of all linear extensions of Finite poset containing 6 elements 1212 sage: L([1, 2, 3, 4, 6, 12]) 1213 Traceback (most recent call last): 1214 ... 1215 TypeError: Cannot convert list to sage.structure.element.Element 1216 1094 1217 .. seealso:: :meth:`linear_extension`, :meth:`is_linear_extension` 1095 1218 1096 1219 EXAMPLES:: … … 1130 1253 sage: type(L[0]) 1131 1254 <type 'list'> 1132 1255 1133 .. todo::1134 1135 The ``facade`` option is not yet fully functional::1136 1137 sage: L = P.linear_extensions(facade=True); L1138 The set of all linear extensions of Finite poset containing 6 elements1139 sage: L([1, 2, 3, 4, 6, 12])1140 Traceback (most recent call last):1141 ...1142 TypeError: Cannot convert list to sage.structure.element.Element1143 1144 1256 TESTS:: 1145 1257 1146 1258 sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] }) … … 1189 1301 1190 1302 EXAMPLES:: 1191 1303 1192 sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] } )1304 sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] }, facade = False) 1193 1305 sage: D.list() 1194 1306 [0, 1, 2, 3, 4] 1195 1307 sage: type(D.list()[0]) … … 1404 1516 1405 1517 def is_lequal(self, x, y): 1406 1518 """ 1407 Returns True if x is less than or equal to yin the poset, and1408 Falseotherwise.1519 Returns ``True`` if `x` is less than or equal to `y` in the poset, and 1520 ``False`` otherwise. 1409 1521 1410 1522 EXAMPLES:: 1411 1523 … … 1428 1540 1429 1541 def is_less_than(self, x, y): 1430 1542 """ 1431 Returns True if x is less than but not equal to y in the poset, and False1432 otherwise.1543 Returns ``True`` if `x` is less than but not equal to `y` in the poset, 1544 and ``False`` otherwise. 1433 1545 1434 1546 EXAMPLES:: 1435 1547 … … 1451 1563 1452 1564 def is_gequal(self, x, y): 1453 1565 """ 1454 Returns True if x is greater than or equal to y in the poset, and1455 Falseotherwise.1566 Returns ``True`` if `x` is greater than or equal to `y` in the poset, 1567 and ``False`` otherwise. 1456 1568 1457 1569 EXAMPLES:: 1458 1570 … … 1477 1589 1478 1590 def is_greater_than(self, x, y): 1479 1591 """ 1480 Returns True if ``x`` is greater than but not equal to ``y``1481 in the poset, and Falseotherwise.1592 Returns ``True`` if `x` is greater than but not equal to `y` in the 1593 poset, and ``False`` otherwise. 1482 1594 1483 1595 EXAMPLES:: 1484 1596 … … 1502 1614 1503 1615 def compare_elements(self, x, y): 1504 1616 r""" 1505 Compare ` `x`` and ``y`` in the poset.1617 Compare `x` and `y` in the poset. 1506 1618 1507 1619 If ``x`` = ``y``, then ``0`` is returned; 1508 1620 if ``x`` < ``y``, then ``-1`` is returned; … … 1732 1844 1733 1845 EXAMPLES:: 1734 1846 1735 sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]] )1847 sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade = False) 1736 1848 sage: P.rank(5) 1737 1849 2 1738 1850 sage: P.rank() … … 1742 1854 sage: P = Posets.SymmetricGroupBruhatOrderPoset(4) 1743 1855 1744 1856 sage: [(v,P.rank(v)) for v in P] 1745 [( 1234, 0),1746 ( 1324, 1),1857 [('1234', 0), 1858 ('1324', 1), 1747 1859 ... 1748 ( 4231, 5),1749 ( 4321, 6)]1860 ('4231', 5), 1861 ('4321', 6)] 1750 1862 """ 1751 1863 if element is None: 1752 1864 return len(self.level_sets())-1 … … 1991 2103 1992 2104 EXAMPLES:: 1993 2105 1994 sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]] )2106 sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade = False) 1995 2107 sage: LEQM = P.lequal_matrix(); LEQM 1996 2108 [1 1 1 1 1 1 1 1] 1997 2109 [0 1 0 1 0 0 0 1] … … 2054 2166 2055 2167 EXAMPLES:: 2056 2168 2057 sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]] )2169 sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade = False) 2058 2170 sage: M = P.meet_matrix(); M 2059 2171 [0 0 0 0 0 0 0 0] 2060 2172 [0 1 0 1 0 0 0 1] … … 2079 2191 2080 2192 EXAMPLES:: 2081 2193 2082 sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]] )2194 sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade = False) 2083 2195 sage: P.is_meet_semilattice() 2084 2196 True 2085 2197 … … 2101 2213 2102 2214 EXAMPLES:: 2103 2215 2104 sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]] )2216 sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade = False) 2105 2217 sage: J = P.join_matrix(); J 2106 2218 [0 1 2 3 4 5 6 7] 2107 2219 [1 1 3 3 7 7 7 7] … … 2355 2467 2356 2468 EXAMPLES:: 2357 2469 2358 sage: P = Poset((divisors(12), attrcall("divides")), linear_extension=True )2470 sage: P = Poset((divisors(12), attrcall("divides")), linear_extension=True, facade = False) 2359 2471 sage: P.list() 2360 2472 [1, 2, 3, 4, 6, 12] 2361 2473 sage: P.cover_relations() … … 2369 2481 Here we relabel the elements of a poset by {0,1,2, ...}, using 2370 2482 a dictionary:: 2371 2483 2372 sage: P = Poset((divisors(12), attrcall("divides")), linear_extension=True )2484 sage: P = Poset((divisors(12), attrcall("divides")), linear_extension=True, facade = False) 2373 2485 sage: relabelling = {c.element:i for (i,c) in enumerate(P)}; relabelling 2374 2486 {1: 0, 2: 1, 3: 2, 4: 3, 6: 4, 12: 5} 2375 2487 sage: Q = P.relabel(relabelling) … … 2496 2608 2497 2609 EXAMPLES:: 2498 2610 2499 sage: P = Poset({"a":["c","d"], "b":["d","e"], "c":["f"], "d":["f"], "e":["f"]} )2611 sage: P = Poset({"a":["c","d"], "b":["d","e"], "c":["f"], "d":["f"], "e":["f"]}, facade = False) 2500 2612 sage: Q = P.subposet(["a","b","f"]); Q 2501 2613 Finite poset containing 3 elements 2502 2614 sage: Q.cover_relations() … … 2512 2624 2513 2625 One may specified wrapped elements or not:: 2514 2626 2515 sage: P = Poset({"a":["c","d"], "b":["d","e"], "c":["f"], "d":["f"], "e":["f"]} )2627 sage: P = Poset({"a":["c","d"], "b":["d","e"], "c":["f"], "d":["f"], "e":["f"]}, facade = False) 2516 2628 sage: Q = P.subposet([P("a"),P("b"),P("f")]); Q 2517 2629 Finite poset containing 3 elements 2518 2630 sage: Q.cover_relations() … … 2627 2739 :: 2628 2740 2629 2741 sage: dg = DiGraph({"a":["b","c"], "b":["d"], "c":["d"]}) 2630 sage: P = Poset(dg )2742 sage: P = Poset(dg, facade = False) 2631 2743 sage: P.interval("a","d") 2632 2744 [a, c, b, d] 2633 2745 """ … … 2669 2781 :: 2670 2782 2671 2783 sage: dg = DiGraph({"a":["b","c"], "b":["d"], "c":["d"]}) 2672 sage: P = Poset(dg )2784 sage: P = Poset(dg, facade = False) 2673 2785 sage: P.open_interval("a","d") 2674 2786 [c, b] 2675 2787 """ … … 2810 2922 2811 2923 EXAMPLES:: 2812 2924 2813 sage: P = Poset(([1,2], [[1,2]]) )2925 sage: P = Poset(([1,2], [[1,2]]), facade = False) 2814 2926 sage: P.promotion() 2815 2927 Finite poset containing 2 elements 2816 2928 sage: P == P.promotion() … … 2895 3007 2896 3008 EXAMPLES:: 2897 3009 2898 sage: P = Poset(([1,2], [[1,2]]) )3010 sage: P = Poset(([1,2], [[1,2]]), facade = False) 2899 3011 sage: P.evacuation() 2900 3012 Finite poset containing 2 elements 2901 3013 sage: P.evacuation() == P 2902 3014 True 2903 3015 2904 sage: P = Poset(([1,2,3,4,5,6,7], [[1,2],[1,4],[2,3],[2,5],[3,6],[4,7],[5,6]]), linear_extension = True )3016 sage: P = Poset(([1,2,3,4,5,6,7], [[1,2],[1,4],[2,3],[2,5],[3,6],[4,7],[5,6]]), linear_extension = True, facade = False) 2905 3017 sage: P.list() 2906 3018 [1, 2, 3, 4, 5, 6, 7] 2907 3019 sage: Q = P.evacuation(); Q -
sage/combinat/root_system/associahedron.py
diff --git a/sage/combinat/root_system/associahedron.py b/sage/combinat/root_system/associahedron.py
a b 32 32 33 33 An Associahedron 34 34 35 The generalized associahedron is a polytopal complex with vertices 36 in one-to-one correspondence with clusters in the cluster complex,37 and with edges between two vertices if and only if the associated38 two clustersintersect in codimension 1.35 The generalized associahedron is a polytopal complex with vertices in 36 one-to-one correspondence with clusters in the cluster complex, and with 37 edges between two vertices if and only if the associated two clusters 38 intersect in codimension 1. 39 39 40 The associahedron of type `A_n` is one way to realize the 41 classical associahedron as defined in40 The associahedron of type `A_n` is one way to realize the classical 41 associahedron as defined in :wikipedia:`Associahedron` 42 42 43 http://en.wikipedia.org/wiki/Associahedron. 44 45 A polytopal realization of the associahedron can be found in [CFZ]. 46 The implementation is based on [CFZ, Theorem 1.5, Remark 1.6, and Corollary 1.9.]. 43 A polytopal realization of the associahedron can be found in [CFZ]. The 44 implementation is based on [CFZ, Theorem 1.5, Remark 1.6, and Corollary 45 1.9.]. 47 46 48 47 EXAMPLES:: 49 48 -
sage/geometry/polyhedron/base.py
diff --git a/sage/geometry/polyhedron/base.py b/sage/geometry/polyhedron/base.py
a b 270 270 271 271 face_lattice = self.face_lattice() 272 272 for face in face_lattice: 273 Vrep = face. element.ambient_Vrepresentation()273 Vrep = face.ambient_Vrepresentation() 274 274 if len(Vrep) == 2: 275 275 set_adjacent(Vrep[0], Vrep[1]) 276 276