Lbase3 = nx.linalg.spectrum.adjacency_spectrum(triFrame, weight='deg') # reflect eigs about origin for laplacians if laplacian: xs = -xs plt.hold(True) #plt.plot(xs, np.abs(Lanalytic), 'g-', linewidth=2) plt.plot(xs, np.abs(Lanalytic2), 'r-', linewidth=2) plt.ylim((0, 0.5)) plt.xlim(xlim) # A = tri.block_gaussian_guess(n, pA, pB) # Lguess = eigvalsh(A, check_finite=False) # Lguess /= np.sqrt(n) # plt.hist(Lguess, bins=301, normed=True) #from IPython import embed if not laplacian: P, K, Q = triFrame.base_matrices() Keigs = eigvals(K) Kmax = Keigs.max() plt.plot((Kmax, Kmax), (0.01, 0.5), 'g--') raw_input("Enter to continue") #embed() nx.write_gml(g, graph_file) # from nonbacktracking import * # B=nonbacktracking_matrix(g) # from scipy.sparse.linalg import eigs as speigs # B_eig1=speigs(B,k=1)[0][0] # print B_eig1 # Bsm=nonbacktracking_matrix_guess(triFrame)
epsilon = 0.001 offset = 0.5 N = 400 num_eig = 10 d = 6 ps = {0: 0.5, 1: 0.5} eset = [(0, 0), (0, 1), (1, 0), (1, 1)] deg = {(0, 0): d + 9, (0, 1): d, (1, 0): d, (1, 1): d + 9} g = Frame(nx.Graph(eset), p=ps, deg=deg) gsamp = g.sample(N) # rho = compute_spectrum(gsamp) # rho.sort() Pdiag, K, Q, P = g.base_matrices() As = nx.adjacency_matrix(gsamp).todense() I = nx.incidence_matrix(gsamp, oriented=True).todense() D, V = eigh(K) print "frame eigenvalues:" print D Ds, Vs = eigh(As) Ds = np.flip(Ds, axis=0) Vs = np.flip(Vs, axis=1) print "ESD leading eigenvalues:" print Ds[:num_eig] Ps = As / np.tile(np.sum(As, axis=1), (1, As.shape[1])).astype(float) DPs, VPs = eig(Ps) Bs = non_backtracking_matrix(gsamp) Bs = sp.csr_matrix(Bs)