def __init__(self, graph, n_eigs, alpha, weight=None):
     SGFT.__init__(self, graph, n_eigs)
     self.graph = graph
     self.factory = ppr.PersonalizedPageRank(graph, n_eigs, weight=weight)
     self.alpha = alpha + self.factory.eig_val[0]
     self.basis = self.factory.basis
     vol = utils.graph_volume(graph, weight)
     self.normalization_constant = np.power(vol, 0.5)
Beispiel #2
0
    def __init__(self, graph, k, weight=None):
        if k >= graph.num_vertices():
            raise ValueError('k must be in the range ' +
                             '[0, graph.num_vertices()). ' +
                             'This is due to scipy.sparse.linalg restrictions')

        self.lap = gt_spectral.laplacian(graph, normalized=True, weight=weight)
        self.adj = gt_spectral.adjacency(graph, weight=weight)
        self._deg_vec = np.asarray(self.adj.sum(axis=1))

        self._weight = weight

        self._vol_graph = utils.graph_volume(graph, self._weight)
        self._n = graph.num_vertices()
        self._vertex_index = graph.vertex_index

        self.eig_val, self.eig_vec = eigsh(self.lap, k, which='SM')

        self._deg_vec = np.asarray(self.adj.sum(axis=1))
        self.basis = np.multiply(np.power(self._deg_vec, -0.5), self.eig_vec)
        self._deg_vec = np.squeeze(self._deg_vec)