Learn R Programming

NetSim (version 0.9)

create_network: Create an network object and maintain it

Description

Create a network object in NetSim from a matrix, set particular ties of the network and transform it back into a matrix

Usage

create_network(matrix, directed = TRUE, reflexive = FALSE) set_tie(network, i, j, value) network_as_matrix(network) "as.matrix"(x, ...) "print"(x, ...)

Arguments

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

See Also

create_process_state create_attribute_container add_random_ties_to_network add_ring_lattice_to_network

Examples

Run this code
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)

Run the code above in your browser using DataLab