Learn R Programming

backbone (version 1.3.1)

class.convert: Convert graph object to adjacency matrix

Description

Convert graph object to adjacency matrix

Usage

class.convert(graph, convert = "matrix", extract = FALSE)

Arguments

graph

matrix, sparse matrix, igraph, edgelist, or network object

convert

class to convert to, one of "matrix", "sparseMatrix", "igraph", "edgelist", or "network"

extract

Boolean, TRUE if using function within backbone.extract, FALSE if not.

Value

list(class, adjacency), a list containing the class of parameter graph, and the adjacency matrix of the graph

Details

An object is considered an edgelist if it is (1) a matrix or sparse matrix, and (2) has only two columns. Each column is understood as a bipartite set, with edges only going between members of column 1 and members of column 2.

Examples

Run this code
# NOT RUN {
davis.sp <- as(davis, "sparseMatrix")
# }
# NOT RUN {
davis.graph <- igraph::graph.incidence(davis)
# }
# NOT RUN {
davis.nw <- network::network(davis, ignore.eval = FALSE,
    names.eval = "weight", loops = TRUE)
# }
# NOT RUN {
backbone:::class.convert(davis, "matrix")
# }
# NOT RUN {
backbone:::class.convert(davis.sp, "matrix")
# }
# NOT RUN {
backbone:::class.convert(davis.graph, "matrix")
# }
# NOT RUN {
backbone:::class.convert(davis.nw, "matrix")
# }
# NOT RUN {
bb.sdsm <- sdsm(davis)
# }
# NOT RUN {
bb <- backbone.extract(bb.sdsm, signed = TRUE, alpha = .2)
# }
# NOT RUN {
backbone:::class.convert(bb, "matrix")
# }
# NOT RUN {
backbone:::class.convert(bb, "sparseMatrix")
# }
# NOT RUN {
backbone:::class.convert(bb, "igraph")
# }
# NOT RUN {
backbone:::class.convert(bb, "network")
# }

Run the code above in your browser using DataLab