Created
November 20, 2018 16:36
-
-
Save tavimori/12d6d455b6451962029a9bb7aa56678a to your computer and use it in GitHub Desktop.
count of automorphism for CSC3001 Assignment 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from itertools import permutations | |
''' | |
for a permutation to be valid | |
A - B | |
A - C | |
A - D | |
B - E | |
B - G | |
C - I | |
C - J | |
D - F | |
D - H | |
E - F | |
E - J | |
F - I | |
G - H | |
G - I | |
H - J | |
ABCDEFGHIJ | |
0123456789 | |
For the reshuffled 'reduced', the original points now sit in the new location. | |
We need to verify the new shape has the same topology with the previous one. | |
For example, if we have the reshuffle: | |
[(0, 4, 6),...] | |
We want to make sure that the (0, 4, 6) at new '0' position does connect to | |
that he is required to connect, i.e. it connect to ... | |
''' | |
if __name__ == '__main__': | |
count = 0 | |
automorphism_count = 0 | |
raw_ind = [(1, 2, 3), (0, 4, 6), (0, 8, 9), (0, 5, 7), (1, 5, 9), | |
(3, 4, 8), (1, 7, 8), (3, 6, 9), (2, 5, 6), (2, 4, 7)] | |
raw = [('A', 'BCD'), ('B', 'AEG'), ('C', 'AIJ'), ('D', 'AFH'), ( | |
'E', 'BFJ'), ('F', 'DEI'), ('G', 'BIH'), ('H', 'GJD'), ('I', 'CFG'), | |
('J', 'CEH')] | |
# [for i in raw] | |
for test in permutations(raw, 10): | |
value = True | |
for i, v in enumerate(raw_ind): | |
for j in v: | |
if test[j][0] not in test[i][1]: | |
value = False | |
# originally this need to connect to position[v] | |
# we need to check if the new item satisfy the requirement | |
if value: | |
automorphism_count += 1 | |
count += 1 | |
if not (count % 100000): | |
print('# of iteration: ', count, ', # of founded:', | |
automorphism_count) | |
# we don't count itself | |
automorphism_count -= 1 | |
print('# of automorphisms: ', automorphism_count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment