Changeset 8614:6e54905ea249
- Timestamp:
- 02/05/08 23:03:02 (5 years ago)
- Branch:
- default
- Location:
- sage/graphs
- Files:
-
- 2 edited
-
graph_isom.pxd (modified) (1 diff)
-
graph_isom.pyx (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/graphs/graph_isom.pxd
r8098 r8614 73 73 cdef int _first_smallest_nontrivial(self, int *W, int k, int n) 74 74 cdef void _get_permutation_from(self, PartitionStack zeta, int *gamma) 75 cdef _enumerate_graph_from_discrete(self, int **G, int n) 75 cdef int _compare_with(self, int **G, int n, PartitionStack other) 76 77 cdef int _is_automorphism(int **G, int n, int *gamma) -
sage/graphs/graph_isom.pyx
r8250 r8614 577 577 s = m 578 578 while alpha[s] != -1: 579 if alpha[s] == j: alpha[s] = t # TODO this will only happen once, so should break 579 if alpha[s] == j: 580 alpha[s] = t 581 break 580 582 s += 1 583 while alpha[s] != -1: s += 1 581 584 r = j 582 585 while True: … … 619 622 s = m 620 623 while alpha[s] != -1: 621 if alpha[s] == j: alpha[s] = t # this will only happen once, so should break 624 if alpha[s] == j: 625 alpha[s] = t 626 break 622 627 s += 1 628 while alpha[s] != -1: s += 1 623 629 r = j 624 630 while True: … … 713 719 i += 1 714 720 if self.levels[i-1] == -1: break 715 716 # (TODO) 717 # Important note: the enumeration should be kept abstract, and only comparison 718 # functions should be written. This takes up too much memory and time. Simply 719 # iterate starting with the most significant digit in the matrix, and return 720 # as soon as a contradiction is encountered. 721 722 cdef _enumerate_graph_from_discrete(self, int **G, int n): 721 722 cdef int _compare_with(self, int **G, int n, PartitionStack other): 723 723 cdef int i, j 724 enumeration = Integer(0)725 724 for i from 0 <= i < n: 726 725 for j from 0 <= j < n: 727 if G[i][j]: 728 enumeration += Integer(2)**((n-(self.entries[i]+1))*n + n-(self.entries[j]+1)) 729 return enumeration 730 731 cdef _enumerate_graph_with_permutation(int **G, int n, int *gamma): 726 if G[self.entries[i]][self.entries[j]]: 727 if not G[other.entries[i]][other.entries[j]]: 728 return 1 729 elif G[other.entries[i]][other.entries[j]]: 730 return -1 731 return 0 732 733 cdef int _is_automorphism(int **G, int n, int *gamma): 732 734 cdef int i, j 733 enumeration = Integer(0)734 735 for i from 0 <= i < n: 735 736 for j from 0 <= j < n: 736 737 if G[i][j]: 737 enumeration += Integer(2)**((n-(gamma[i]+1))*n + n-(gamma[j]+1)) 738 return enumeration 739 740 cdef _enumerate_graph(int **G, int n): 741 cdef int i, j # enumeration = 0 742 enumeration = Integer(0) 743 for i from 0 <= i < n: 744 for j from 0 <= j < n: 745 if G[i][j]: 746 enumeration += Integer(2)**((n-(i+1))*n + n-(j+1)) 747 return enumeration 738 if not G[gamma[i]][gamma[j]]: 739 return 0 740 return 1 748 741 749 742 def _term_pnest_graph(G, PartitionStack nu): … … 1162 1155 46080 1163 1156 """ 1164 cdef int i, j, # local variables1157 cdef int i, j, m # local variables 1165 1158 1166 1159 cdef OrbitPartition Theta, OP … … 1329 1322 nu = PartitionStack(Pi) 1330 1323 Theta = OrbitPartition(n) 1331 G_enum = _enumerate_graph(M, n)1332 1324 output = [] 1333 1325 if dig: _dig = 1 … … 1526 1518 1527 1519 if verbosity > 3: 1528 print ' automorphism discovered:'1520 print 'checking for automorphism:' 1529 1521 print [gamma[iii] for iii in range(n)] 1530 1522 1531 # if G^gamma == G, the permutation is an automorphism,goto 101532 if G_enum == _enumerate_graph_with_permutation(M, n, gamma):1523 # if G^gamma == G, goto 10 1524 if _is_automorphism(M, n, gamma): 1533 1525 state = 10 1534 1526 else: … … 1548 1540 state = 9; continue 1549 1541 1550 # if G(nu) > G(rho), goto 9 1551 # if G(nu) < G(rho), goto 6 1552 # if G(nu) == G(rho), get the automorphism and goto 10 1553 m1 = nu._enumerate_graph_from_discrete(M, n) 1554 m2 = rho._enumerate_graph_from_discrete(M, n) 1555 1556 if m1 > m2: 1542 # if G(nu) > G(rho) (returns 1), goto 9 1543 # if G(nu) < G(rho) (returns -1), goto 6 1544 # if G(nu) == G(rho) (returns 0), get the automorphism and goto 10 1545 m = nu._compare_with(M, n, rho) 1546 1547 if m > 0: 1557 1548 state = 9; continue 1558 if m 1 < m2:1549 if m < 0: 1559 1550 state = 6; continue 1560 1551
Note: See TracChangeset
for help on using the changeset viewer.
