Skip to content

Commit

Permalink
Improve PolynomialSequence.connection_graph()
Browse files Browse the repository at this point in the history
Simplify the code; also, the previous code has to iterate over variables
of the sequence twice (this is really bad before #35510)
  • Loading branch information
tornaria committed Apr 15, 2023
1 parent 97b45d8 commit abf1c80
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/sage/rings/polynomial/multi_polynomial_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,15 +908,10 @@ def connection_graph(self):
sage: F.connection_graph()
Graph on 3 vertices
"""
V = sorted(self.variables())
from sage.graphs.graph import Graph
g = Graph()
g.add_vertices(sorted(V))
for f in self:
v = f.variables()
a,tail = v[0],v[1:]
for b in tail:
g.add_edge((a,b))
g.add_path(f.variables())
return g

def connected_components(self):
Expand Down

0 comments on commit abf1c80

Please sign in to comment.