1 | #Generalized toggling code - I is the subset you are toggling and v is the toggle you are applying |
---|

2 | def gentoggle(listofsubsets,I,v): |
---|

3 | from sage.sets.set import Set |
---|

4 | if not v in I: |
---|

5 | if I.union(Set({v})) in listofsubsets: |
---|

6 | return I.union(Set({v})) |
---|

7 | else: |
---|

8 | if I.difference(Set({v})) in listofsubsets: |
---|

9 | return I.difference(Set({v})) |
---|

10 | return I |
---|

11 | |
---|

12 | #this is for toggling by vs which is a list of toggles |
---|

13 | def gentoggles(listofsubsets,I,vs): |
---|

14 | for v in vs: |
---|

15 | I = gentoggle(listofsubsets,I,v) |
---|

16 | return I |
---|

17 | |
---|

18 | #this is to display the orbits of toggling listofsubsets by the list of toggles vs |
---|

19 | def gentoggling_orbits(listofsubsets,vs): |
---|

20 | OI = list(listofsubsets) |
---|

21 | orbits = [] |
---|

22 | while OI: |
---|

23 | A = OI.pop() |
---|

24 | orbit = [ A ] |
---|

25 | while True: |
---|

26 | A = gentoggles(listofsubsets, A, vs) |
---|

27 | if A==orbit[0]: break |
---|

28 | orbit.append( A ) |
---|

29 | OI.remove( A ) |
---|

30 | orbits.append(orbit) |
---|

31 | return orbits |
---|

32 | |
---|

33 | |
---|

34 | |
---|

35 | |
---|

36 | |
---|

37 | |
---|

38 | |
---|

39 | |
---|