def test_comet(self, n=100, k=10): graph = graphs.Comet(n, k) self.assertEqual(graph.n_vertices, n) self.assertEqual(graph.n_edges, n - 1) self.assertEqual(graph.dw[0], k) graph = graphs.Comet(7, 4) adjacency = [ [0, 1, 1, 1, 1, 0, 0], # center [1, 0, 0, 0, 0, 0, 0], # branch [1, 0, 0, 0, 0, 0, 0], # branch [1, 0, 0, 0, 0, 0, 0], # branch [1, 0, 0, 0, 0, 1, 0], # tail [0, 0, 0, 0, 1, 0, 1], # tail [0, 0, 0, 0, 0, 1, 0], # tail ] np.testing.assert_array_equal(graph.W.toarray(), adjacency) coords = [[0, 0], [0, 1], [-1, 0], [0, -1], [1, 0], [2, 0], [3, 0]] np.testing.assert_allclose(graph.coords, coords, atol=1e-10) # Comet generalizes Path. g1 = graphs.Comet(n, 0) g2 = graphs.Path(n) np.testing.assert_array_equal(g1.W.toarray(), g2.W.toarray()) # Comet generalizes Star. g1 = graphs.Comet(n, n - 1) g2 = graphs.Star(n) np.testing.assert_array_equal(g1.W.toarray(), g2.W.toarray())
def test_comet(self): graphs.Comet()
from pygsp import graphs, filters import matplotlib.pyplot as plt import numpy as np G = graphs.Comet() G.compute_fourier_basis() # Fourier to plot the eigenvalues. # lmax = G.estimate_lmax() # print('{:.2f}'.format(G.lmax)) DELTAS = [2, 20] s = np.zeros(G.N) s[DELTAS] = 1 # Fig.1 fig = plt.figure(figsize=(25, 15)) ax = fig.add_subplot(3, 3, 1) G.plot(s, ax=ax) g = filters.Meyer(G) # g = filters.Meyer(G,scales=[5,2,1,0.6,0.4]) scales = [0] + g.scales.tolist() print(scales) s = g.filter(s, method='exact') # g2 = filters.Heat(G, scale=5) # s2 = g2.filter(s) ax = fig.add_subplot(3, 3, 2) title = 'Meyer Scaling(scale={})'.format(scales[0]) G.plot(s[:, 0], ax=ax, title=title) # G.plot(s[:, 0], ax=ax, title='Meyer Scaling', highlight=DELTAS) ax.set_axis_off() for i in range(1, 6):
def test_Comet(): G = graphs.Comet()
def test_Comet(): G = graphs.Comet() needed_attributes_testing(G)