1.4. igraph_weighted_adjacency — Creates a graph object from a weighted adjacency matrix.

int igraph_weighted_adjacency(igraph_t *graph, igraph_matrix_t *adjmatrix,
		     igraph_adjacency_t mode, const char* attr);

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 weighted adjacency matrix. How it is interpreted depends on the mode argument. The common feature is that edges with zero weights are considered nonexistent (however, negative weights are permitted).

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 weight of the edge 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 weight of the edge between vertex i and j is max(A(i,j), A(j,i)).

IGRAPH_ADJ_MIN

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

IGRAPH_ADJ_PLUS

undirected graph will be created with edge weight A(i,j)+A(j,i) 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 edge weights.

IGRAPH_ADJ_LOWER

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

attr:

the name of the attribute that will store the edge weights. If NULL , it will use weight as the attribute name.

Returns: 

Error code, IGRAPH_NONSQUARE: non-square matrix.

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