Movatterモバイル変換


[0]ホーム

URL:


igraph Reference Manual

For using the igraph C library

Search the manual:

Chapter 27. Embedding of graphs

1. Spectral embedding

1.1. igraph_adjacency_spectral_embedding — Adjacency spectral embedding

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: 

graph:

The input graph, can be directed or undirected.

n:

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.

weights:

Optional edge weights. Supply a null pointer for unweighted graphs.

which:

Which eigenvalues (or singular values, for directed graphs) to use, possible values:

IGRAPH_EIGEN_LM

the ones with the largest magnitude

IGRAPH_EIGEN_LA

the (algebraic) largest ones

IGRAPH_EIGEN_SA

the (algebraic) smallest ones.

For directed graphs,IGRAPH_EIGEN_LM andIGRAPH_EIGEN_LA are the same because singular values are used for the ordering instead of eigenvalues.

scaled:

Whether to return X and Y (ifscaled is true), or U and V.

X:

Initialized matrix, the estimated latent positions are stored here.

Y:

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.)

D:

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.

cvec:

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:

Options to ARPACK. Seeigraph_arpack_options_t for details. SupplyNULL to use the defaults. Note that the function overwrites then (number of vertices),nev andwhich parameters and it always starts the calculation from a random start vector.

Returns: 

Error code.

1.2. igraph_laplacian_spectral_embedding — Spectral embedding of the Laplacian of a graph

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: 

graph:

The input graph.

n:

The number of eigenvectors (or singular vectors if the graph is directed) to use for the embedding.

weights:

Optional edge weights. Supply a null pointer for unweighted graphs.

which:

Which eigenvalues (or singular values, for directed graphs) to use, possible values:

IGRAPH_EIGEN_LM

the ones with the largest magnitude

IGRAPH_EIGEN_LA

the (algebraic) largest ones

IGRAPH_EIGEN_SA

the (algebraic) smallest ones.

For directed graphs,IGRAPH_EIGEN_LM andIGRAPH_EIGEN_LA are the same because singular values are used for the ordering instead of eigenvalues.

type:

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:

IGRAPH_EMBEDDING_D_A

means D - A where D is the degree matrix and A is the adjacency matrix

IGRAPH_EMBEDDING_DAD

means Di times A times Di, where Di is the inverse of the square root of the degree matrix;

IGRAPH_EMBEDDING_I_DAD

means I - Di A Di, where I is the identity matrix.

scaled:

Whether to return X and Y (ifscaled is true), or U and V.

X:

Initialized matrix, the estimated latent positions are stored here.

Y:

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.)

D:

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:

Options to ARPACK. Seeigraph_arpack_options_t for details. SupplyNULL to use the defaults. Note that the function overwrites then (number of vertices),nev andwhich parameters and it always starts the calculation from a random start vector.

Returns: 

Error code.

See also: 

igraph_adjacency_spectral_embedding to embed the adjacencymatrix.

1.3. igraph_dim_select — Dimensionality selection.

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: 

sv:

A numeric vector, the ordered singular values.

dim:

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 graphsChapter 28. Graph operators →

© 2003 – 2025 The igraph core team. • Code licensed under GNU GPL 2 or later, documentation underGNU FDL.


[8]ページ先頭

©2009-2025 Movatter.jp