@@ -460,16 +460,16 @@ def contract_edge(self, k):
460
460
#the following two lines convert the list of tuples to list of lists
461
461
aux_sigma = [list (x ) for x in self ._sigma .cycle_tuples (singletons = True )]
462
462
aux_rho = [list (x ) for x in self ._rho .cycle_tuples ()]
463
- #The following ''if'' rules out the cases when we would be
464
- #contracting a loop (which is not admissible since we would
463
+ #The following ''if'' rules out the cases when we would be
464
+ #contracting a loop (which is not admissible since we would
465
465
#lose the topological type of the graph).
466
- if (_find (aux_sigma , aux_rho [k ][0 ])[0 ] ==
466
+ if (_find (aux_sigma , aux_rho [k ][0 ])[0 ] ==
467
467
_find (aux_sigma , aux_rho [k ][1 ])[0 ]):
468
468
raise ValueError ("the edge is a loop and cannot be contracted" )
469
469
#We store in auxiliary variables the positions of the vertices
470
470
#that are the ends of the edge to be contracted and we delete
471
471
#from them the darts corresponding to the edge that is going
472
- #to be contracted. We also delete the contracted edge
472
+ #to be contracted. We also delete the contracted edge
473
473
#from aux_rho
474
474
pos1 = _find (aux_sigma , aux_rho [k ][0 ])
475
475
pos2 = _find (aux_sigma , aux_rho [k ][1 ])
@@ -582,7 +582,7 @@ def extrude_edge(self, vertex, dart1, dart2):
582
582
for val in val_one :
583
583
repr_sigma += [[val ]]
584
584
585
- # We find which is the highest value a dart has, in order to
585
+ # We find which is the highest value a dart has, in order to
586
586
# add new darts that do not conflict with previous ones.
587
587
k = max (darts_rho )
588
588
@@ -627,7 +627,7 @@ def genus(self):
627
627
"""
628
628
#We now use the same procedure as in _repr_ to get the vertices
629
629
#of valency 1 and distinguish them from the extra singletons of
630
- #the permutation sigma.
630
+ #the permutation sigma.
631
631
repr_sigma = [list (x ) for x in self ._sigma .cycle_tuples ()]
632
632
repr_rho = [list (x ) for x in self ._rho .cycle_tuples ()]
633
633
darts_rho = flatten (repr_rho )
@@ -637,10 +637,10 @@ def genus(self):
637
637
#the total number of vertices of sigma is its number of cycles
638
638
#of length >1 plus the number of singletons that are actually
639
639
#vertices of valency 1
640
-
640
+
641
641
vertices = len (self ._sigma .cycle_tuples ()) + len (val_one )
642
642
edges = len (self ._rho .cycle_tuples ())
643
- #formula for the genus using that the thickening is homotopically
643
+ #formula for the genus using that the thickening is homotopically
644
644
#equivalent to the graph
645
645
g = (- vertices + edges - self .number_boundaries () + 2 ) // 2
646
646
@@ -720,13 +720,13 @@ def boundary(self):
720
720
bound = []
721
721
722
722
#since lists of tuples are not modifiable, we change the data to a
723
- #list of lists
723
+ #list of lists
724
724
aux_perm = (self ._rho * self ._sigma ).cycle_tuples (singletons = True )
725
725
726
- #the cycles of the permutation rho*sigma are in 1:1 correspondence with
726
+ #the cycles of the permutation rho*sigma are in 1:1 correspondence with
727
727
#the boundary components of the thickening (see function number_boundaries())
728
728
#but they are not the labeled boundary components.
729
- #With the next for, we convert the cycles of rho*sigma to actually
729
+ #With the next for, we convert the cycles of rho*sigma to actually
730
730
#the labelling of the edges. Each edge, therefore, should appear twice
731
731
732
732
for i ,p in enumerate (aux_perm ):
@@ -799,16 +799,16 @@ def reduced(self):
799
799
aux_sigma = [list (x ) for x in aux_ribbon ._sigma .cycle_tuples (singletons = True )]
800
800
aux_rho = [list (x ) for x in aux_ribbon ._rho .cycle_tuples ()]
801
801
for j in range (len (aux_rho )):
802
- if (_find (aux_sigma , aux_rho [j ][0 ])[0 ] !=
802
+ if (_find (aux_sigma , aux_rho [j ][0 ])[0 ] !=
803
803
_find (aux_sigma , aux_rho [j ][1 ])[0 ]):
804
804
aux_ribbon = aux_ribbon .contract_edge (j )
805
- aux_rho = [list (x ) for
805
+ aux_rho = [list (x ) for
806
806
x in aux_ribbon ._rho .cycle_tuples ()]
807
807
break
808
808
#finally we change the data to a list of tuples and return the
809
- #information as a ribbon graph.
809
+ #information as a ribbon graph.
810
810
return aux_ribbon
811
-
811
+
812
812
#the next function computes a basis of homology, it uses
813
813
#the previous function.
814
814
@@ -960,15 +960,15 @@ def homology_basis(self):
960
960
961
961
basis = [[list (x )] for x in self .reduced ()._rho .cycle_tuples ()]
962
962
963
- #Now we define center as the set of edges that were contracted
964
- #in reduced() this set is contractible and can be define as the
963
+ #Now we define center as the set of edges that were contracted
964
+ #in reduced() this set is contractible and can be define as the
965
965
#complement of reduced_rho in rho
966
966
967
- center = [list (x ) for x in self ._rho .cycle_tuples ()
967
+ center = [list (x ) for x in self ._rho .cycle_tuples ()
968
968
if (x not in self .reduced ()._rho .cycle_tuples ())]
969
969
970
970
#We define an auxiliary list 'vertices' that will contain the
971
- #vertices (cycles of sigma) corresponding to each half edge.
971
+ #vertices (cycles of sigma) corresponding to each half edge.
972
972
973
973
vertices = []
974
974
@@ -1013,7 +1013,7 @@ def homology_basis(self):
1013
1013
basis [i ][j ][0 ], basis [i ][j ][1 ] = \
1014
1014
basis [i ][j ][1 ], basis [i ][j ][0 ]
1015
1015
1016
- #the variable basis is a LIST of Lists of lists. Each List
1016
+ #the variable basis is a LIST of Lists of lists. Each List
1017
1017
#corresponds to an element of the basis and each list in a List
1018
1018
#is just a 2-tuple which corresponds to an ''ordered'' edge of rho.
1019
1019
@@ -1056,7 +1056,7 @@ def normalize(self):
1056
1056
darts_rho = flatten (aux_rho )
1057
1057
darts_sigma = flatten (aux_sigma )
1058
1058
val_one = [x for x in darts_rho if x not in darts_sigma ]
1059
-
1059
+
1060
1060
#We add them to aux_sigma
1061
1061
for i in range (len (val_one )):
1062
1062
aux_sigma += [[val_one [i ]]]
@@ -1147,7 +1147,7 @@ def make_ribbon(g, r):
1147
1147
repr_sigma [1 ].append (i + (2 * g + 2 )+ 1 )
1148
1148
repr_rho += [[i + 2 ,i + (2 * g + 2 )+ 1 ]]
1149
1149
1150
- #finally we add an edge for each additional boundary component.
1150
+ #finally we add an edge for each additional boundary component.
1151
1151
max_dart = 4 * g + 2
1152
1152
for j in range (r - 1 ):
1153
1153
repr_sigma [0 ].insert (0 , max_dart + 2 * (j + 1 )- 1 )
0 commit comments