2525from sage .sandpiles .sandpile import Sandpile
2626from sage .graphs .graph_generators import graphs
2727
28- class SandpileExamples ():
28+
29+ class SandpileExamples :
2930 """
3031 Some examples of sandpiles.
3132
@@ -92,7 +93,7 @@ def Complete(self, n):
9293 sage: sandpiles.Complete(3) == sandpiles.Cycle(3)
9394 True
9495 """
95- return Sandpile (graphs .CompleteGraph (n ),0 )
96+ return Sandpile (graphs .CompleteGraph (n ), 0 )
9697
9798 def Cycle (self , n ):
9899 """
@@ -119,7 +120,7 @@ def Cycle(self, n):
119120 (3, 0, 1),
120121 (3, 2, 1)]
121122 """
122- return Sandpile (graphs .CycleGraph (n ),0 )
123+ return Sandpile (graphs .CycleGraph (n ), 0 )
123124
124125 def Diamond (self ):
125126 """
@@ -164,18 +165,18 @@ def Fan(self, n, deg_three_verts=False):
164165 """
165166 f = graphs .WheelGraph (n )
166167 if n > 2 :
167- f .delete_edge (1 ,n - 1 )
168+ f .delete_edge (1 , n - 1 )
168169 if deg_three_verts :
169170 f .allow_multiple_edges (True )
170- f .add_edges ([(0 ,1 ),(0 ,n - 1 )])
171- return Sandpile (f ,0 )
171+ f .add_edges ([(0 , 1 ), (0 , n - 1 )])
172+ return Sandpile (f , 0 )
172173 elif n == 1 :
173- return Sandpile (f ,0 )
174+ return Sandpile (f , 0 )
174175 elif n == 2 :
175176 if deg_three_verts :
176- return Sandpile ({0 :{1 :3 }, 1 :{0 :3 }})
177+ return Sandpile ({0 : {1 : 3 }, 1 : {0 : 3 }})
177178 else :
178- return Sandpile (f ,0 )
179+ return Sandpile (f , 0 )
179180
180181 def Grid (self , m , n ):
181182 """
@@ -200,11 +201,12 @@ def Grid(self, m, n):
200201 sage: s.dict()
201202 {(0, 0): {(1, 1): 4}, (1, 1): {(0, 0): 4}}
202203 """
203- G = graphs .Grid2dGraph (m + 2 ,n + 2 )
204+ G = graphs .Grid2dGraph (m + 2 , n + 2 )
204205 G .allow_multiple_edges (True ) # to ensure each vertex ends up with degree 4
205- V = [(i ,j ) for i in [0 ,m + 1 ] for j in range (n + 2 )] + [(i ,j ) for j in [0 ,n + 1 ] for i in range (m + 2 )]
206+ V = [(i , j ) for i in [0 , m + 1 ] for j in range (n + 2 )]
207+ V += [(i , j ) for j in [0 , n + 1 ] for i in range (m + 2 )]
206208 G .merge_vertices (V )
207- return Sandpile (G , (0 ,0 ))
209+ return Sandpile (G , (0 , 0 ))
208210
209211 def House (self ):
210212 """
@@ -224,7 +226,7 @@ def House(self):
224226 sage: s.invariant_factors()
225227 [1, 1, 1, 11]
226228 """
227- return Sandpile (graphs .HouseGraph (),0 )
229+ return Sandpile (graphs .HouseGraph (), 0 )
228230
229231 def Wheel (self , n ):
230232 """
@@ -244,7 +246,7 @@ def Wheel(self, n):
244246 sage: w.invariant_factors()
245247 [1, 1, 1, 11, 11]
246248 """
247- return Sandpile (graphs .WheelGraph (n ),0 )
249+ return Sandpile (graphs .WheelGraph (n ), 0 )
248250
249251
250252sandpiles = SandpileExamples ()
0 commit comments