Description Usage Arguments Value Examples
View source: R/adjacency_matrix.R
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'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | 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 class '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 class '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 class '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 class '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 class '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 class '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 class 'sparseMatrix'
get_adjacency(
x,
select_cols = NULL,
multiedge = NULL,
aggr_expression = NULL,
nodes = NULL,
sparse = TRUE,
drop_names = FALSE,
directed = NULL,
selfloops = NULL,
...
)
## Default S3 method:
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 class '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'.
1 2 3 4 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.