Advertisement
JoelSjogren

unnormalized structure constants

Apr 1st, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.25 KB | None | 0 0
  1. import networkx as nx
  2. import numpy as np
  3.  
  4. """
  5. K4 = nx.complete_graph(4)
  6. K33 = nx.complete_bipartite_graph(3, 3)
  7. Petersen = nx.petersen_graph()
  8. Cube = nx.hypercube_graph(3)
  9. Heawood = nx.heawood_graph()
  10. Pappus = nx.pappus_graph()
  11. Coxeter = None
  12. Tutte = nx.tutte_graph()
  13. Dodecahedron = nx.dodecahedral_graph()
  14. Desargues = nx.desargues_graph()
  15. Biggs = None
  16. Foster = None
  17. smith1971 = [K4, K33, Petersen, Cube, Heawood, Pappus, Coxeter, Tutte, Dodecahedron, Desargues, Biggs, Foster]
  18. """
  19.  
  20. # intersection numbers 'iota'
  21. K4 = [[3], [1]]
  22. K33 = [[3, 2], [1, 3]]
  23. Petersen = [[3, 2], [1, 1]]
  24. Cube = [[3, 2, 1], [1, 2, 3]]
  25. Heawood = [[3, 2, 2], [1, 1, 3]]
  26. Pappus = [[3, 2, 2, 1], [1, 1, 2, 3]]
  27. Coxeter = [[3, 2, 2, 1], [1, 1, 1, 2]]
  28. Tutte = [[3, 2, 2, 2], [1, 1, 1, 3]]
  29. Dodecahedron = [[3, 2, 1, 1, 1], [1, 1, 1, 2, 3]]
  30. Desargues = [[3, 2, 2, 1, 1], [1, 1, 2, 2, 3]]
  31. Biggs = [[3, 2, 2, 2, 1, 1, 1], [1, 1, 1, 1, 1, 1, 3]]
  32. Foster = [[3, 2, 2, 2, 2, 1, 1, 1], [1, 1, 1, 1, 2, 2, 2, 3]]
  33.  
  34. smith1971 = [K4, K33, Petersen, Cube, Heawood, Pappus, Coxeter, Tutte, Dodecahedron, Desargues, Biggs, Foster]
  35.  
  36. """
  37. From Wolfram:
  38.     Given a distance-regular graph G with integers  b_i,c_i,i=0,...,d such that for any two vertices
  39.     x,y in G at distance i=d(x,y), there are exactly c_i neighbors of y in G_(i-1)(x) and b_i neighbors of y in G_(i+1)(x), the sequence
  40.         iota(gamma)={b_0,b_1,...,b_(d-1);c_1,...,c_d}
  41.     is called the intersection array of G.
  42. See also https://en.wikipedia.org/wiki/Distance-regular_graph.
  43. N_ij^k = B^i_jk
  44. """
  45. def intersection_array_to_unnormalized_constants(iota):
  46.     diam = len(iota[0])
  47.     b = lambda i: iota[0][i] if i in range(diam) else 0
  48.     c = lambda i: iota[1][i-1] if i-1 in range(diam) else 0
  49.     a = lambda i: b(0) - b(i) - c(i)
  50.  
  51.     B = np.zeros((diam+1, diam+1), dtype=int)
  52.     B[0,:2] = a(0), b(0)
  53.     for i in range(1, diam):
  54.         B[i,i-1:i+2] = c(i), a(i), b(i)
  55.     B[-1,-2], B[-1,-1] = c(diam), a(diam)
  56.  
  57.     N = [np.linalg.matrix_power(B, i) for i in range(diam+1)]
  58.     return np.array(N)
  59.  
  60. #def intersection_array_to_structure_constants(iota):
  61. #   N = intersection_array_to_unnormalized_constants(iota)
  62.  
  63. def demo(which=range(12)):
  64.     for i in which:
  65.         print(intersection_array_to_unnormalized_constants(smith1971[i]))
  66.  
  67. if __name__ == '__main__':
  68.     demo()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement