mat2Edge: Adjacency matrix to a data.frame of edges.

View source: R/edge2Mat.R

mat2EdgeR Documentation

Adjacency matrix to a data.frame of edges.

Description

Adjacency matrix to a data.frame of edges.

Usage

mat2Edge(
  mat,
  mode = c("directed", "undirected", "upper", "lower"),
  diag = FALSE
)

Arguments

mat

adjacency matrix.

mode

Character, to specify the class of graph and which part of the matrix will be used. Possible values are: "directed" (default), "undirected", "upper", "lower".

diag

logic, whether to include the diagonal of the matrix.

Value

a data.frame of edge information. The first column is from node, the second column is to node, and the third is weight.

See Also

edge2Mat

Examples

{
## Not run: 
mat = matrix(rnorm(4*4), nrow = 4,
             dimnames = list(letters[1:4], LETTERS[1:4]))
mat2Edge(mat, mode = "undirected", diag = TRUE)
mat2Edge(mat, mode = "undirected", diag = FALSE)
mat2Edge(mat, mode = "directed", diag = TRUE)
mat2Edge(mat, mode = "upper", diag = TRUE)
mat2Edge(mat, mode = "upper", diag = FALSE)

## End(Not run)
}

paodan/funcTools documentation built on April 1, 2024, 12:01 a.m.