Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
speeding up twograph_descendant
Browse files Browse the repository at this point in the history
e.g. on a 275-vertex graph:

sage: g=graphs.McLaughlinGraph()
sage: timeit('g.twograph_descendant(0)')
5 loops, best of 3: 76.7 ms per loop
  • Loading branch information
dimpase committed Aug 18, 2015
1 parent 2fae2fc commit 799a2bf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/sage/graphs/graph.py
Expand Up @@ -5131,9 +5131,11 @@ def twograph_descendant(self, v):
sage: T8.twograph_descendant(v).is_strongly_regular(parameters=True)
(27, 16, 10, 8)
"""
Nv = self.neighbors(v)
NonNv = filter(lambda x: not x in Nv and x != v, self.vertices())
return Graph([Nv+NonNv, lambda i, j:
Nv0 = self.neighbors(v)
Nv = frozenset(Nv0)
NonNv0 = filter(lambda x: not x in Nv and x != v, self.vertices())
NonNv = frozenset(NonNv0)
return Graph([Nv0+NonNv0, lambda i, j:
(i in NonNv and j in NonNv and self.has_edge(i,j)) or
(i in Nv and j in Nv and self.has_edge(i,j)) or
(i in Nv and j in NonNv and not self.has_edge(i,j)) or
Expand Down

0 comments on commit 799a2bf

Please sign in to comment.