Skip to content

Commit c2f4f7b

Browse files
committed
some care for graphs in sage/combinat/posets/lattices.py
1 parent cae3aac commit c2f4f7b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/sage/combinat/posets/lattices.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,13 +1805,13 @@ def is_relatively_complemented(self, certificate=False):
18051805
return False
18061806

18071807
for e1 in range(n - 1):
1808-
C = Counter(flatten([H.neighbors_out(e2) for e2 in H.neighbors_out(e1)]))
1808+
C = Counter(flatten([H.neighbors_out(e2) for e2 in H.neighbor_out_iterator(e1)]))
18091809
for e3, c in C.items():
18101810
if c == 1 and len(H.closed_interval(e1, e3)) == 3:
18111811
if not certificate:
18121812
return False
1813-
for e2 in H.neighbors_in(e3):
1814-
if e2 in H.neighbors_out(e1):
1813+
for e2 in H.neighbor_in_iterator(e3):
1814+
if e2 in H.neighbor_out_iterator(e1):
18151815
break
18161816
return (False, (self._vertex_to_element(e1),
18171817
self._vertex_to_element(e2),
@@ -1885,7 +1885,7 @@ def is_sectionally_complemented(self, certificate=False):
18851885
n = H.order() - 1
18861886
for e in range(2, n + 1):
18871887
t = n
1888-
for lc in H.neighbors_in(e):
1888+
for lc in H.neighbor_in_iterator(e):
18891889
t = mt[t, lc]
18901890
if t == 0:
18911891
break
@@ -1988,7 +1988,7 @@ def join(L):
19881988

19891989
# Get elements more than B levels below it.
19901990
too_close = set(H.breadth_first_search(j,
1991-
neighbors=H.neighbors_in,
1991+
neighbors=H.neighbor_in_iterator,
19921992
distance=B - 2))
19931993
elems = [e for e in H.order_ideal([j]) if e not in too_close]
19941994

@@ -2378,7 +2378,7 @@ def is_atomic(self, certificate=False):
23782378
if self.cardinality() < 3:
23792379
return (True, None)
23802380
H = self._hasse_diagram
2381-
atoms = set(H.neighbors_out(0))
2381+
atoms = set(H.neighbor_out_iterator(0))
23822382
for v in H:
23832383
if H.in_degree(v) == 1 and v not in atoms:
23842384
return (False, self._vertex_to_element(v))
@@ -2436,7 +2436,7 @@ def is_coatomic(self, certificate=False):
24362436
if self.cardinality() < 3:
24372437
return (True, None)
24382438
H = self._hasse_diagram
2439-
coatoms = set(H.neighbors_in(n - 1))
2439+
coatoms = set(H.neighbor_in_iterator(n - 1))
24402440
for v in H:
24412441
if H.out_degree(v) == 1 and v not in coatoms:
24422442
return (False, self._vertex_to_element(v))
@@ -3782,8 +3782,8 @@ def is_dismantlable(self, certificate=False):
37823782
if certificate:
37833783
cert.append(e)
37843784
if i == 1 and o == 1: # Remove inside the lattice
3785-
lower = H.neighbors_in(e)[0]
3786-
upper = H.neighbors_out(e)[0]
3785+
lower = next(H.neighbor_in_iterator(e))
3786+
upper = next(H.neighbor_out_iterator(e))
37873787
H.delete_vertex(e)
37883788
if upper not in H.depth_first_search(lower):
37893789
H.add_edge(lower, upper)
@@ -4125,11 +4125,11 @@ def canonical_meetands(self, e):
41254125
H = self._hasse_diagram
41264126
e = self._element_to_vertex(e)
41274127
meetands = []
4128-
for a in H.neighbors_out(e):
4129-
above_a = list(H.depth_first_search(a))
4128+
for a in H.neighbor_out_iterator(e):
4129+
above_a = set(H.depth_first_search(a))
41304130

41314131
def go_up(v):
4132-
return [v_ for v_ in H.neighbors_out(v) if v_ not in above_a]
4132+
return [v_ for v_ in H.neighbor_out_iterator(v) if v_ not in above_a]
41334133

41344134
result = None
41354135
for v in H.depth_first_search(e, neighbors=go_up):
@@ -4191,11 +4191,11 @@ def canonical_joinands(self, e):
41914191
H = self._hasse_diagram
41924192
e = self._element_to_vertex(e)
41934193
joinands = []
4194-
for a in H.neighbors_in(e):
4195-
below_a = list(H.depth_first_search(a, neighbors=H.neighbors_in))
4194+
for a in H.neighbor_in_iterator(e):
4195+
below_a = set(H.depth_first_search(a, neighbors=H.neighbor_in_iterator))
41964196

41974197
def go_down(v):
4198-
return [v_ for v_ in H.neighbors_in(v) if v_ not in below_a]
4198+
return [v_ for v_ in H.neighbor_in_iterator(v) if v_ not in below_a]
41994199

42004200
result = None
42014201
for v in H.depth_first_search(e, neighbors=go_down):

0 commit comments

Comments
 (0)