network
network copied to clipboard
does `as.sna.edgelist = TRUE` argument to `as.edgelist` behave as intended?
e.g.
require(network)
nw <- network.initialize(2, directed = FALSE)
nw[1,2] <- 1
as.matrix.network.edgelist(nw, as.sna.edgelist = FALSE)
as.matrix.network.edgelist(nw, as.sna.edgelist = TRUE)
as.edgelist(nw, as.sna.edgelist = FALSE)
as.edgelist(nw, as.sna.edgelist = TRUE)
produces
> as.matrix.network.edgelist(nw, as.sna.edgelist = FALSE)
[,1] [,2]
[1,] 1 2
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
> as.matrix.network.edgelist(nw, as.sna.edgelist = TRUE)
[,1] [,2] [,3]
[1,] 1 2 1
[2,] 2 1 1
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
> as.edgelist(nw, as.sna.edgelist = FALSE)
[,1] [,2]
[1,] 1 2
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
attr(,"directed")
[1] FALSE
attr(,"bipartite")
[1] FALSE
attr(,"loops")
[1] FALSE
attr(,"class")
[1] "matrix_edgelist" "edgelist" "matrix" "array"
> as.edgelist(nw, as.sna.edgelist = TRUE)
[,1] [,2] [,3]
[1,] 1 2 1
attr(,"n")
[1] 2
attr(,"vnames")
[1] 1 2
attr(,"directed")
[1] FALSE
attr(,"bipartite")
[1] FALSE
attr(,"loops")
[1] FALSE
attr(,"class")
[1] "matrix_edgelist" "edgelist" "matrix" "array"
i.e. the screening of edges in as.edgelist.matrix
(which does not receive or recognize as.sna.edgelist
in the current implementation) is dropping the "reversed" edge 2 1
from the output when as.sna.edgelist = TRUE
is passed to as.edgelist
, which seems like not what we want for sna
(based on the behavior of as.matrix.network.edgelist
).