Skip to content

Commit e85d67f

Browse files
committed
faster Hochschild lattices
1 parent 931cc5e commit e85d67f

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/sage/combinat/posets/hochschild_lattice.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import Iterator
2020

2121
from sage.combinat.posets.lattices import LatticePoset
22+
from sage.graphs.digraph import DiGraph
2223
from sage.topology.simplicial_complex import SimplicialComplex
2324

2425

@@ -84,12 +85,23 @@ def sommets(n) -> Iterator[tuple[int, ...]]:
8485
for w in iterator_False(n - 1):
8586
yield (1,) + w
8687

87-
verts = list(sommets(n))
88-
89-
def compare(a, b) -> bool:
90-
return all(ai <= bi for ai, bi in zip(a, b))
91-
92-
return LatticePoset([verts, compare])
88+
verts = frozenset(sommets(n))
89+
90+
def cover_relations(a):
91+
for i, ai in enumerate(a):
92+
if not ai:
93+
continue
94+
b = list(a)
95+
for k in range(ai - 1, -1, -1):
96+
b[i] = k
97+
tb = tuple(b)
98+
if tb in verts:
99+
yield tb
100+
break
101+
102+
dg = DiGraph({a: list(cover_relations(a)) for a in verts},
103+
format="dict_of_lists")
104+
return LatticePoset(dg.reverse(), cover_relations=True, check=False)
93105

94106

95107
def hochschild_fan(n):

0 commit comments

Comments
 (0)