Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # dx7hymcxnpq
- # 2012.06.29
- import copy
- def chkTups( s, edgeSet ):
- total_incidence = 0
- for edge in edgeSet:
- if s in edge:
- total_incidence += 1
- return ((total_incidence) % 2 == 0)
- K5 = [ [1,2], [1,3], [1,4], [1,5], [2,3], [2,4], [2,5], [3,4], [3,5], [4,5] ]
- K34 = [ [1,4], [1,5], [1,6], [1,7], [2,4], [2,5], [2,6], [2,7], [3,4], [3,5], [3,6], [3,7] ]
- CUBE = [ [1,2], [1,4], [2,3], [3,4], [5,6], [5,8], [6,7], [7,8], [1,5], [2,6], [3,7], [4,8] ]
- def powerset( s ):
- if len(s) == 0: return [[]]
- L = powerset( s[1:] )
- M = []
- for k in L:
- p = copy.deepcopy(k)
- if not (s[0] in p): p.append(s[0])
- M.append(k)
- M.append(p)
- return M
- Possibilities = powerset(K5)
- CycleSpace = []
- for subset in Possibilities:
- failed = 0
- # now check all the vertices --
- for i in range(1,6):
- if not chkTups(i,subset): failed = 1
- if not failed:
- CycleSpace.append(subset)
- #print "The cycle space is: \n"
- #print CycleSpace
- print "IT HAS SIZE %s" % len(CycleSpace)
- Possibilities = powerset(K34)
- CycleSpace = []
- for subset in Possibilities:
- failed = 0
- for i in range(1,8):
- if not chkTups(i, subset): failed = 1
- if not failed:
- CycleSpace.append(subset)
- print "IT HAS SIZE %s" % len(CycleSpace)
- Possibilities = powerset(CUBE)
- CycleSpace = []
- for subset in Possibilities:
- failed = 0
- for i in range(1,9):
- if not chkTups(i, subset): failed = 1
- if not failed:
- CycleSpace.append(subset)
- print "IT HAS SIZE %s" % len(CycleSpace)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement