get_adjacency.Rd
If `x` is a tibble or a dataframe, `get_adjacency` assumes that it has been passed an edgelist. If `x` is a matrix, `get_adjacency` assumes that it has been passed an incidence matrix and constructs the corresponding adjacency matrix. If `x` is a different object, `get_adjacency` uses the appropriate method if it exists. Otherwise it tries to coerce `x` to a `data.frame`.
get_adjacency( x, select_cols = NULL, multiedge = NULL, aggr_expression = NULL, nodes = NULL, sparse = TRUE, drop_names = FALSE, directed = NULL, selfloops = NULL, edgelist = NULL, ... ) # S3 method for tbl get_adjacency( x, select_cols = NULL, multiedge = NULL, aggr_expression = NULL, nodes = NULL, sparse = TRUE, drop_names = FALSE, directed = NULL, selfloops = NULL, edgelist = NULL, ... ) # S3 method for tbl_graph get_adjacency( x, select_cols = NULL, multiedge = NULL, aggr_expression = NULL, nodes = NULL, sparse = TRUE, drop_names = FALSE, directed = NULL, selfloops = NULL, edgelist = NULL, ... ) # S3 method for data.frame get_adjacency( x, select_cols = NULL, multiedge = NULL, aggr_expression = NULL, nodes = NULL, sparse = TRUE, drop_names = FALSE, directed = NULL, selfloops = NULL, edgelist = NULL, ... ) # S3 method for matrix get_adjacency( x, select_cols = NULL, multiedge = NULL, aggr_expression = NULL, nodes = NULL, sparse = TRUE, drop_names = FALSE, directed = NULL, selfloops = NULL, edgelist = NULL, ... ) # S3 method for dgTMatrix get_adjacency( x, select_cols = NULL, multiedge = NULL, aggr_expression = NULL, nodes = NULL, sparse = TRUE, drop_names = FALSE, directed = NULL, selfloops = NULL, ... ) # S3 method for dgCMatrix get_adjacency( x, select_cols = NULL, multiedge = NULL, aggr_expression = NULL, nodes = NULL, sparse = TRUE, drop_names = FALSE, directed = NULL, selfloops = NULL, ... ) # S3 method for sparseMatrix get_adjacency( x, select_cols = NULL, multiedge = NULL, aggr_expression = NULL, nodes = NULL, sparse = TRUE, drop_names = FALSE, directed = NULL, selfloops = NULL, ... ) # S3 method for default get_adjacency( x, select_cols = NULL, multiedge = NULL, aggr_expression = NULL, nodes = NULL, sparse = TRUE, drop_names = FALSE, directed = NULL, selfloops = NULL, ... ) # S3 method for igraph get_adjacency( x, select_cols = NULL, multiedge = NULL, aggr_expression = NULL, nodes = NULL, sparse = TRUE, drop_names = FALSE, directed = NULL, selfloops = NULL, ... )
x | object from which generating the adjacency matrix |
---|---|
select_cols | optional vector of 3 (2 for multi-graphs) elements
specifying which columns are the source,target, and attributes from which
building the graph. Otherwise Column 1 is assumed to be the source, column
2 the target, column 3 the attribute. In the case of multi-graphs, the
third element is not needed and the number of edges between each pair of
vertices is computed according to ' |
multiedge | boolean, are there multiple edges? defaults to FALSE. |
aggr_expression | string, the expression used to compute the aggregated
value in the adjacency matrix in the presence of multiedges. It defaults to
' |
nodes | optional vector containing all node names in case disconnected nodes should be included. |
sparse | boolean, return sparse matrix? default to TRUE |
drop_names | boolean, drop names from matrix and return a vector of names together with the matrix. This option saves considerable memory when dealing with graphs with long node names. |
directed | boolean, optional parameter, if FALSE, forces to undirected upper triangular adjacency matrix |
selfloops | boolean, optional parameter, if ignores selfloops. |
edgelist | optional boolean. If `x` is a matrix, should treat `x` as an edgelist? If not provided, tries to infer if `x` is an edgelist or an incidence matrix from its shape. |
... | additional parameters to and from the main method. Currently not used. |
A transition matrix in the same format of `adj`.
el <- data.frame(from= c('a','b','b','c','d','d'), to = c('b','c','d','a','b','a'), attr= c( 12, 6, 12 , 6 , 6 , 6 )) adj <- get_adjacency(el)