1
1
# -*- coding: utf-8 -*-
2
- # sage.doctest: needs sage.graphs sage.modules sage.plot sage.rings.finite_rings
2
+ # sage.doctest: needs sage.graphs sage.modules
3
3
r"""
4
4
Finite posets
5
5
@@ -434,15 +434,16 @@ def Poset(data=None, element_labels=None, cover_relations=False, linear_extensio
434
434
With a function that identifies the cover relations: the set
435
435
partitions of `\{1, 2, 3\}` ordered by refinement::
436
436
437
- sage: elms = SetPartitions(3) # needs sage.combinat
437
+ sage: # optional - sage.combinat
438
+ sage: elms = SetPartitions(3)
438
439
sage: def fcn(A, B):
439
440
....: if len(A) != len(B)+1:
440
441
....: return False
441
442
....: for a in A:
442
443
....: if not any(set(a).issubset(b) for b in B):
443
444
....: return False
444
445
....: return True
445
- sage: Poset((elms, fcn), cover_relations=True) # needs sage.combinat
446
+ sage: Poset((elms, fcn), cover_relations=True)
446
447
Finite poset containing 5 elements
447
448
448
449
3. A dictionary of upper covers::
@@ -1932,12 +1933,14 @@ def plot(self, label_elements=True, element_labels=None,
1932
1933
1933
1934
This function can be used without any parameters::
1934
1935
1936
+ sage: # optional - sage.plot
1935
1937
sage: D12 = posets.DivisorLattice(12)
1936
1938
sage: D12.plot()
1937
1939
Graphics object consisting of 14 graphics primitives
1938
1940
1939
1941
Just the abstract form of the poset; examples of relabeling::
1940
1942
1943
+ sage: # optional - sage.plot
1941
1944
sage: D12.plot(label_elements=False)
1942
1945
Graphics object consisting of 8 graphics primitives
1943
1946
sage: d = {1: 0, 2: 'a', 3: 'b', 4: 'c', 6: 'd', 12: 1}
@@ -1949,12 +1952,14 @@ def plot(self, label_elements=True, element_labels=None,
1949
1952
1950
1953
Some settings for coverings::
1951
1954
1955
+ sage: # optional - sage.plot
1952
1956
sage: d = {(a, b): b/a for a, b in D12.cover_relations()}
1953
1957
sage: D12.plot(cover_labels=d, cover_color='gray', cover_style='dotted')
1954
1958
Graphics object consisting of 21 graphics primitives
1955
1959
1956
1960
To emphasize some elements and show some options::
1957
1961
1962
+ sage: # optional - sage.plot
1958
1963
sage: L = LatticePoset({0: [1, 2, 3, 4], 1: [12], 2: [6, 7],
1959
1964
....: 3: [5, 9], 4: [5, 6, 10, 11], 5: [13],
1960
1965
....: 6: [12], 7: [12, 8, 9], 8: [13], 9: [13],
@@ -1973,6 +1978,7 @@ def plot(self, label_elements=True, element_labels=None,
1973
1978
1974
1979
We check that ``label_elements`` and ``element_labels`` are honored::
1975
1980
1981
+ sage: # optional - sage.plot
1976
1982
sage: def get_plot_labels(P):
1977
1983
....: return sorted(t.string for t in P
1978
1984
....: if isinstance(t, sage.plot.text.Text))
@@ -1990,6 +1996,7 @@ def plot(self, label_elements=True, element_labels=None,
1990
1996
1991
1997
The following checks that :trac:`18936` has been fixed and labels still work::
1992
1998
1999
+ sage: # optional - sage.plot
1993
2000
sage: P = Poset({0: [1,2], 1:[3]})
1994
2001
sage: heights = {1 : [0], 2 : [1], 3 : [2,3]}
1995
2002
sage: P.plot(heights=heights)
@@ -2000,6 +2007,7 @@ def plot(self, label_elements=True, element_labels=None,
2000
2007
2001
2008
The following checks that equal labels are allowed (:trac:`15206`)::
2002
2009
2010
+ sage: # optional - sage.plot
2003
2011
sage: P = Poset({1: [2,3]})
2004
2012
sage: labs = {i: P.rank(i) for i in range(1, 4)}; labs
2005
2013
{1: 0, 2: 1, 3: 1}
@@ -2008,6 +2016,7 @@ def plot(self, label_elements=True, element_labels=None,
2008
2016
2009
2017
The following checks that non-hashable labels are allowed (:trac:`15206`)::
2010
2018
2019
+ sage: # optional - sage.plot
2011
2020
sage: P = Poset({1: [2,3]})
2012
2021
sage: labs = {1: [2, 3], 2: [], 3: []}; labs
2013
2022
{1: [2, 3], 2: [], 3: []}
@@ -2016,6 +2025,7 @@ def plot(self, label_elements=True, element_labels=None,
2016
2025
2017
2026
Plot of the empty poset::
2018
2027
2028
+ sage: # optional - sage.plot
2019
2029
sage: P = Poset({})
2020
2030
sage: P.plot()
2021
2031
Graphics object consisting of 0 graphics primitives
@@ -2103,6 +2113,7 @@ def show(self, label_elements=True, element_labels=None,
2103
2113
2104
2114
EXAMPLES::
2105
2115
2116
+ sage: # optional - sage.plot
2106
2117
sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] })
2107
2118
sage: D.plot(label_elements=False)
2108
2119
Graphics object consisting of 6 graphics primitives
@@ -2112,9 +2123,9 @@ def show(self, label_elements=True, element_labels=None,
2112
2123
2113
2124
One more example with cover labels::
2114
2125
2126
+ sage: # optional - sage.plot
2115
2127
sage: P = posets.PentagonPoset()
2116
2128
sage: P.show(cover_labels=lambda a, b: a - b)
2117
-
2118
2129
"""
2119
2130
# We split the arguments into those meant for plot() and those meant for show()
2120
2131
#
@@ -6710,12 +6721,14 @@ def order_ideal_plot(self, elements):
6710
6721
6711
6722
EXAMPLES::
6712
6723
6724
+ sage: # optional - sage.plot
6713
6725
sage: P = Poset((divisors(1000), attrcall("divides")))
6714
6726
sage: P.order_ideal_plot([20, 25])
6715
6727
Graphics object consisting of 41 graphics primitives
6716
6728
6717
6729
TESTS::
6718
6730
6731
+ sage: # optional - sage.plot
6719
6732
sage: P = Poset() # Test empty poset
6720
6733
sage: P.order_ideal_plot([])
6721
6734
Graphics object consisting of 0 graphics primitives
0 commit comments