@@ -8541,35 +8541,53 @@ def cuts(self):
85418541 A cut is a subset `A` of ``self`` such that the set of lower
85428542 bounds of the set of upper bounds of `A` is exactly `A`.
85438543
8544- The cuts are computed here using the maximal independent sets in the
8545- auxiliary graph defined as `P \times [0,1]` with an edge
8546- from `(x, 0)` to `(y, 1)` if
8547- and only if `x \not\geq_P y`. See the end of section 4 in [JRJ94]_.
8544+ The cuts are computed as the smallest family of subsets of P containing its
8545+ principal order filters, the whose set P and which is closed by intersection.
85488546
85498547 EXAMPLES::
85508548
85518549 sage: P = posets.AntichainPoset(3)
85528550 sage: Pc = P.cuts()
85538551 sage: Pc # random
8554- [frozenset({0}),
8552+ [frozenset({2}),
8553+ frozenset({1}),
8554+ frozenset({0}),
85558555 frozenset(),
8556- frozenset({0, 1, 2}),
8557- frozenset({2}),
8558- frozenset({1})]
8556+ frozenset({0, 1, 2})]
85598557 sage: sorted(list(c) for c in Pc)
85608558 [[], [0], [0, 1, 2], [1], [2]]
85618559
8560+ TESTS::
8561+
8562+ sage: P = Poset()
8563+ sage: P.cuts()
8564+ [frozenset()]
8565+
85628566 .. SEEALSO::
85638567
85648568 :meth:`completion_by_cuts`
85658569 """
8566- from sage .graphs .graph import Graph
8567- from sage .graphs .independent_sets import IndependentSets
8568- auxg = Graph ({(u , 0 ): [(v , 1 ) for v in self if not self .ge (u , v )]
8569- for u in self }, format = 'dict_of_lists' )
8570- auxg .add_vertices ([(v , 1 ) for v in self ])
8571- return [frozenset ([xa for xa , xb in c if xb == 0 ])
8572- for c in IndependentSets (auxg , maximal = True )]
8570+ C , C2 = [], []
8571+ for x in P :
8572+ C .append (set (P .order_filter ([x ])))
8573+ for i , c in enumerate (C ):
8574+ for j in range (i + 1 , len (C )):
8575+ I = c .intersection (C [j ])
8576+ if I not in C + C2 :
8577+ C2 .append (I )
8578+ while C2 :
8579+ D = []
8580+ for x in C :
8581+ for y in C2 :
8582+ I = x .intersection (y )
8583+ if all (I not in X for X in [C , C2 , D ]):
8584+ D .append (I )
8585+ C .extend (C2 )
8586+ C2 = D
8587+ S = set (P )
8588+ if S not in C :
8589+ C .append (S )
8590+ return [frozenset (x ) for x in C ]
85738591
85748592 def completion_by_cuts (self ):
85758593 """
0 commit comments