Description Usage Arguments See Also Examples
Create a network object in NetSim from a matrix, set particular ties of the network and transform it back into a matrix
1 2 3 4 5 6 7 | create_network(matrix, directed = TRUE, reflexive = FALSE)
set_tie(network, i, j, value)
network_as_matrix(network)
## S3 method for class 'NetSimNetwork'
as.matrix(x, ...)
## S3 method for class 'NetSimNetwork'
print(x, ...)
|
matrix |
A (squared) matrix object |
directed |
Indicates whether the network is directed (TRUE) or undirected (FALSE) |
reflexive |
Indicates whether the matrix is reflexive (TRUE) or not (FALSE) |
network |
A NetSim network object |
i,j |
index of one particular tie. The index starts counting from 0. |
value |
A value a tie is set to (1 or 0 in binary networks) |
x |
A NetSim network object |
... |
Additional arguments |
create_process_state
create_attribute_container
add_random_ties_to_network
add_ring_lattice_to_network
1 2 3 4 5 6 7 8 9 10 11 12 | nActors <- 5
network <- create_network(matrix(1, nActors, nActors))
# set ties
set_tie(network, i = 0, j = 1, value = 0)
set_tie(network, i = 0, j = 2, value = 0)
# returns FALSE and keeps the network unchanged as the network is not reflexive
set_tie(network, i = 0, j = 0, value = 1)
# there are two equivalent ways to re-transform the network into a matrix
as.matrix(network)
network_as_matrix(network)
|
Loading required package: Rcpp
Attaching package: 'NetSim'
The following object is masked from 'package:stats':
simulate
Warning: 5 ties could not be set.
[1] TRUE
[1] TRUE
[1] FALSE
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 1 1
[2,] 1 0 1 1 1
[3,] 1 1 0 1 1
[4,] 1 1 1 0 1
[5,] 1 1 1 1 0
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 1 1
[2,] 1 0 1 1 1
[3,] 1 1 0 1 1
[4,] 1 1 1 0 1
[5,] 1 1 1 1 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.