@@ -4173,29 +4173,16 @@ def fundamental_group(self, base_point=None, simplify=True):
4173
4173
from sage .groups .free_group import FreeGroup
4174
4174
from sage .libs .gap .libgap import libgap as gap
4175
4175
G = self .graph ()
4176
- # If the vertices and edges of G are not sortable, e.g., a mix
4177
- # of str and int, Sage+Python 3 may raise a TypeError when
4178
- # trying to find the spanning tree. So create a graph
4179
- # isomorphic to G but with sortable vertices. Use a copy of G,
4180
- # because self.graph() is cached, and relabeling its vertices
4181
- # would relabel the cached version.
4182
- int_to_v = dict (enumerate (G .vertex_iterator ()))
4183
- v_to_int = {v : i for i , v in int_to_v .items ()}
4184
- G2 = G .copy (immutable = False )
4185
- G2 .relabel (v_to_int )
4186
- spanning_tree = G2 .min_spanning_tree ()
4187
- gens = [(int_to_v [e [0 ]], int_to_v [e [1 ]])
4188
- for e in G2 .edges (sort = True )
4189
- if e not in spanning_tree ]
4190
- if len (gens ) == 0 :
4191
- return gap .TrivialGroup ()
4192
-
4193
4176
# Edges in the graph may be sorted differently than in the
4194
4177
# simplicial complex, so convert the edges to frozensets so we
4195
4178
# don't have to worry about it. Convert spanning_tree to a set
4196
4179
# to make lookup faster.
4197
- spanning_tree = set (frozenset ((int_to_v [e [0 ]], int_to_v [e [1 ]]))
4198
- for e in spanning_tree )
4180
+ spanning_tree = set (frozenset ((u , v )) for u , v , _ in G .min_spanning_tree ())
4181
+ gens = [e for e in G .edge_iterator (labels = False )
4182
+ if frozenset (e ) not in spanning_tree ]
4183
+ if not gens :
4184
+ return gap .TrivialGroup ()
4185
+
4199
4186
gens_dict = {frozenset (g ): i for i , g in enumerate (gens )}
4200
4187
FG = FreeGroup (len (gens ), 'e' )
4201
4188
rels = []
@@ -4204,7 +4191,7 @@ def fundamental_group(self, base_point=None, simplify=True):
4204
4191
z = dict ()
4205
4192
for i in range (3 ):
4206
4193
x = frozenset (bdry [i ])
4207
- if ( x in spanning_tree ) :
4194
+ if x in spanning_tree :
4208
4195
z [i ] = FG .one ()
4209
4196
else :
4210
4197
z [i ] = FG .gen (gens_dict [x ])
0 commit comments