1.3. igraph_adjacency — Creates a graph object from an adjacency matrix.

int igraph_adjacency(igraph_t *graph, igraph_matrix_t *adjmatrix,
		     igraph_adjacency_t mode);

The order of the vertices in the matrix is preserved, i.e. the vertex corresponding to the first row/column will be vertex with id 0, the next row is for vertex 1, etc.

Arguments: 

graph:

Pointer to an uninitialized graph object.

adjmatrix:

The adjacency matrix. How it is interpreted depends on the mode argument.

mode:

Constant to specify how the given matrix is interpreted as an adjacency matrix. Possible values (A(i,j) is the element in row i and column j in the adjacency matrix (adjmatrix):

IGRAPH_ADJ_DIRECTED

the graph will be directed and an element gives the number of edges between two vertices.

IGRAPH_ADJ_UNDIRECTED

this is the same as IGRAPH_ADJ_MAX, for convenience.

IGRAPH_ADJ_MAX

undirected graph will be created and the number of edges between vertex i and j is max(A(i,j), A(j,i)).

IGRAPH_ADJ_MIN

undirected graph will be created with min(A(i,j), A(j,i)) edges between vertex i and j.

IGRAPH_ADJ_PLUS

undirected graph will be created with A(i,j)+A(j,i) edges between vertex i and j.

IGRAPH_ADJ_UPPER

undirected graph will be created, only the upper right triangle (including the diagonal) is used for the number of edges.

IGRAPH_ADJ_LOWER

undirected graph will be created, only the lower left triangle (including the diagonal) is used for creating the edges.

Returns: 

Error code, IGRAPH_NONSQUARE: non-square matrix.

Time complexity: O(|V||V|), |V| is the number of vertices in the graph.