| 1922 | def elements_of_the_rank_iterator(self,k): |

| 1923 | r""" |

| 1924 | Rertuns an iterator of the elements of rank k. |

| 1925 | |

| 1926 | INPUT: ``k``: an integer |

| 1927 | |

| 1928 | OUTPUT: an iterator of the elements of rank k. |

| 1929 | |

| 1930 | Examples:: |

| 1931 | |

| 1932 | sage: type(Poset(([0,1,2],[(0,1),(0,2)])).elements_of_the_rank_iterator(1)) |

| 1933 | <type 'generator'> |

| 1934 | |

| 1935 | sage: list(Poset(([0,1,2,3,4],[(0,1),(1,4),(0,2),(2,3),(3,4)])).elements_of_the_rank_iterator(1)) |

| 1936 | Traceback (most recent call last): |

| 1937 | ... |

| 1938 | ValueError: Poset is not ranked |

| 1939 | |

| 1940 | """ |

| 1941 | p = self |

| 1942 | r = p.rank_function() |

| 1943 | if p.is_ranked(): |

| 1944 | for a in p: |

| 1945 | if r(a) == k: |

| 1946 | yield a |

| 1947 | else: |

| 1948 | raise ValueError, "Poset is not ranked" |

| 1949 | |

| 1950 | def elements_of_the_rank(self,k): |

| 1951 | r""" |

| 1952 | Rertuns the list of the elements of rank k. |

| 1953 | |

| 1954 | INPUT: ``k``: an integer |

| 1955 | |

| 1956 | OUTPUT: a list of the elements of rank k. |

| 1957 | |

| 1958 | Examples:: |

| 1959 | |

| 1960 | sage: Poset(([0,1,2],[(0,1),(0,2)])).elements_of_the_rank(1) |

| 1961 | [1, 2] |

| 1962 | |

| 1963 | sage: Poset(([0,1,2,3,4],[(0,1),(1,4),(0,2),(2,3),(3,4)])).elements_of_the_rank(1) |

| 1964 | Traceback (most recent call last): |

| 1965 | ... |

| 1966 | ValueError: Poset is not ranked |

| 1967 | |

| 1968 | """ |

| 1969 | return [ a for a in self.elements_of_the_rank_iterator(k) ] |

| 1970 | |