get_matrix: Converts a vector into an adjacency matrix

View source: R/extra_functions.R

get_matrixR Documentation

Converts a vector into an adjacency matrix

Description

Given a vector that encodes an adjacency matrix, returns the matrix representation.

Usage

get_matrix(beta, type = c("undirected", "directed"))

Arguments

beta

Vectorized adjacency matrix. If the network is undirected, the vector is assumed to represent the upper triangular part of the adjacency matrix in column major order. For undirected network, the vector contains the entries ordered by column and excluding the diagonal elements.

type

Specifies whether the vector represents an undirected or directed network. Default is undirected.

Value

Adjacency matrix.

Examples


# Obtain the adjacency matrix of a COBRE data subject
data(COBRE.data)
A <- get_matrix(COBRE.data$X.cobre[1,], type = "undirected")
plot_adjmatrix(A)


jesusdaniel/graphclass documentation built on Aug. 10, 2022, 3:10 p.m.