File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -8930,22 +8930,35 @@ def __contains__(self, P) -> bool:
89308930 return P in FinitePosets () and P .cardinality () == self ._n
89318931
89328932 def __iter__ (self ):
8933- """
8933+ r """
89348934 Return an iterator of representatives of the isomorphism classes
89358935 of finite posets of a given size.
89368936
89378937 .. NOTE::
89388938
8939- This uses an iterator from ``nauty`` as a backend to construct
8940- transitively-reduced, acyclic digraphs.
8939+ If the size `n\leq 16`, this uses an iterator from
8940+ ``nauty`` as a backend to construct only transitively-reduced,
8941+ acyclic digraphs. Otherwise it uses a slow naive iterator,
8942+ as the ``nauty`` iterator is not available.
89418943
89428944 EXAMPLES::
89438945
89448946 sage: P = Posets(2)
89458947 sage: list(P)
89468948 [Finite poset containing 2 elements, Finite poset containing 2 elements]
8949+
8950+ TESTS::
8951+
8952+ sage: it = iter(Posets(17))
8953+ sage: next(it)
8954+ Finite poset containing 17 elements
89478955 """
8948- for dig in digraphs .nauty_posetg (f"{ self ._n } o" ):
8956+ if self ._n <= 16 :
8957+ it = digraphs .nauty_posetg (f"{ self ._n } o" )
8958+ else :
8959+ it = digraphs (self ._n , is_poset )
8960+
8961+ for dig in it :
89498962 # We need to relabel the digraph since range(self._n) must be a linear
89508963 # extension. Too bad we need to compute this again. TODO: Fix this.
89518964 label_dict = dict (zip (dig .topological_sort (), range (dig .order ())))
You can’t perform that action at this time.
0 commit comments