For using the igraph C library
igraph_error_t igraph_adjacency_spectral_embedding(const igraph_t *graph, igraph_integer_t n, const igraph_vector_t *weights, igraph_eigen_which_position_t which, igraph_bool_t scaled, igraph_matrix_t *X, igraph_matrix_t *Y, igraph_vector_t *D, const igraph_vector_t *cvec, igraph_arpack_options_t *options);
Spectral decomposition of the adjacency matrices of graphs.This function computes ann-dimensional Euclideanrepresentation of the graph based on its adjacencymatrix, A. This representation is computed via the singular valuedecomposition of the adjacency matrix, A=U D V^T. In the case,where the graph is a random dot product graph generated using latentposition vectors in R^n for each vertex, the embedding willprovide an estimate of these latent vectors.
For undirected graphs, the latent positions are calculated asX = U^n D^(1/2) where U^n equals to the first no columns of U, andD^(1/2) is a diagonal matrix containing the square root of the selectedsingular values on the diagonal.
For directed graphs, the embedding is defined as the pairX = U^n D^(1/2), Y = V^n D^(1/2).(For undirected graphs U=V, so it is sufficient to keep one of them.)
Arguments:
| The input graph, can be directed or undirected. | ||||||
| An integer scalar. This value is the embedding dimension of the spectral embedding. Should be smaller than the number of vertices. The largest n-dimensional non-zero singular values are used for the spectral embedding. | ||||||
| Optional edge weights. Supply a null pointer for unweighted graphs. | ||||||
| Which eigenvalues (or singular values, for directed graphs) to use, possible values:
For directed graphs, | ||||||
| Whether to return X and Y (if | ||||||
| Initialized matrix, the estimated latent positions are stored here. | ||||||
| Initialized matrix or a null pointer. If not a null pointer, then the second half of the latent positions are stored here. (For undirected graphs, this always equals X.) | ||||||
| Initialized vector or a null pointer. If not a null pointer, then the eigenvalues (for undirected graphs) or the singular values (for directed graphs) are stored here. | ||||||
| A numeric vector, its length is the number vertices in the graph. This vector is added to the diagonal of the adjacency matrix, before performing the SVD. | ||||||
| Options to ARPACK. See |
Returns:
Error code. |
igraph_error_t igraph_laplacian_spectral_embedding(const igraph_t *graph, igraph_integer_t n, const igraph_vector_t *weights, igraph_eigen_which_position_t which, igraph_laplacian_spectral_embedding_type_t type, igraph_bool_t scaled, igraph_matrix_t *X, igraph_matrix_t *Y, igraph_vector_t *D, igraph_arpack_options_t *options);
This function essentially does the same asigraph_adjacency_spectral_embedding, but works on the Laplacianof the graph, instead of the adjacency matrix.
Arguments:
| The input graph. | ||||||
| The number of eigenvectors (or singular vectors if the graph is directed) to use for the embedding. | ||||||
| Optional edge weights. Supply a null pointer for unweighted graphs. | ||||||
| Which eigenvalues (or singular values, for directed graphs) to use, possible values:
For directed graphs, | ||||||
| The type of the Laplacian to use. Various definitions exist for the Laplacian of a graph, and one can choose between them with this argument. Possible values:
| ||||||
| Whether to return X and Y (if | ||||||
| Initialized matrix, the estimated latent positions are stored here. | ||||||
| Initialized matrix or a null pointer. If not a null pointer, then the second half of the latent positions are stored here. (For undirected graphs, this always equals X.) | ||||||
| Initialized vector or a null pointer. If not a null pointer, then the eigenvalues (for undirected graphs) or the singular values (for directed graphs) are stored here. | ||||||
| Options to ARPACK. See |
Returns:
Error code. |
See also:
|
igraph_error_t igraph_dim_select(const igraph_vector_t *sv, igraph_integer_t *dim);
Dimensionality selection for singular values usingprofile likelihood.
The input of the function is a numeric vector which containsthe measure of "importance" for each dimension.
For spectral embedding, these are the singular values of the adjacencymatrix. The singular values are assumed to be generated from aGaussian mixture distribution with two components that have differentmeans and same variance. The dimensionality d is chosen tomaximize the likelihood when the d largest singular values areassigned to one component of the mixture and the rest of the singularvalues assigned to the other component.
This function can also be used for the general separation problem,where we assume that the left and the right of the vector are comingfrom two normal distributions, with different means, and we wantto know their border.
Arguments:
| A numeric vector, the ordered singular values. |
| The result is stored here. |
Returns:
Error code. |
Time complexity: O(n), n is the number of values in sv.
See also:
| ← Chapter 26. Hierarchical random graphs | Chapter 28. Graph operators → |