Learn R Programming

backbone (version 1.2.1)

class.convert: Convert graph object to adjacency matrix

Description

Convert graph object to adjacency matrix

Usage

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

Arguments

graph

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

convert

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

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